New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to disable gif delta frame optimizations #3603
Comments
The diff: 420a421
> no_frame_optimization = im.encoderinfo.get("no_frame_optimization", im.info.get("no_frame_optimization"))
443,447c444,445
< previous = im_frames[-1]
< if _get_palette_bytes(im_frame) == \
< _get_palette_bytes(previous['im']):
< delta = ImageChops.subtract_modulo(im_frame,
< previous['im'])
---
> if no_frame_optimization:
> bbox = im_frame.getbbox()
449,457c447,461
< delta = ImageChops.subtract_modulo(
< im_frame.convert('RGB'), previous['im'].convert('RGB'))
< bbox = delta.getbbox()
< if not bbox:
< # This frame is identical to the previous frame
< if duration:
< previous['encoderinfo']['duration'] += \
< encoderinfo['duration']
< continue
---
> previous = im_frames[-1]
> if _get_palette_bytes(im_frame) == \
> _get_palette_bytes(previous['im']):
> delta = ImageChops.subtract_modulo(im_frame,
> previous['im'])
> else:
> delta = ImageChops.subtract_modulo(
> im_frame.convert('RGB'), previous['im'].convert('RGB'))
> bbox = delta.getbbox()
> if not bbox:
> # This frame is identical to the previous frame
> if duration:
> previous['encoderinfo']['duration'] += \
> encoderinfo['duration']
> continue |
Could you provide
|
I've attached sprite data and 4 scripts. Two which will produce desired outputs(using a work around of background colour normalizing) and two which produce undesired outputs(using no background normalizing). |
The fix is described in #3665 |
#3708 has fixed the cropping, so the first gif now produces correct output with disposal 2 - but the second has an unexpected green box. |
For the second, your input images have two different transparent colours. They were being translated to two different palette indexes, and GIF can only use one as transparency. I've created #5282 to resolve this, by setting all fully transparent pixels to the same color. |
#5282 has been merged, solving the second part. |
I feel it would be nice/useful to have the option to disable delta frame (allowing full frame redraw). Delta Frame can cause issues with specific types of animations.
A case example would be a animation which uses transparency. It will need to overwrite pixels that are no longer used, but delta frames will crop out these pixels resulting in a broken animation, leaving the programmer with one of two types of images:
Example of a implementation:
GifImagePlugin.py.diff.txt (Had to save it as a .txt because for some reason Github doesn't allow diff of all file types to reject)
Attached diff is messy, could be optimized (doesn't disable cropping code), and the name probably could be less long.
--
Edit: This might actually be a bug?
Turns out the issue only seems to occur if the background transparency data in a png contains color information and isn't empty/same color.
The text was updated successfully, but these errors were encountered: