Repository navigation
Do not allow base image info to set disposal or blend - #10273
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #10061
When saving a GIF or PNG with multiple frames, you can specify the
disposalorblendthrough a keyword argument, likeHowever, if the user doesn't provide a keyword argument when saving, Pillow will fallback to the base image's
info.Pillow/src/PIL/GifImagePlugin.py
Line 664 in 2e758a2
Pillow/src/PIL/PngImagePlugin.py
Lines 1207 to 1208 in 2e758a2
When a single integer is in the
disposal, GIF ignores it. GIF doesn't write "disposal" toinfowhen opening.im.info["disposal"] = (0, 1, 2)is the only scenario for which this would make a difference, butinfo["disposal"]isn't documented at https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#gif-saving, so I suggest removing it.For PNG, a single integer in
disposalandblendvariables aren't used for that specific frame only, they are the default for all frames of all images. It isn't a documented feature atand https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#apng-saving. I consider this unexpected.
If you would like a demonstration of the unexpected behaviour, #10061 notes that roundtripping

produces

The test code that I'm removing here was added in #5611.