Use previous disposal method in GIF load_end #5125
Merged
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.
Resolves #3153
Animated GIFs have subsequent frames encoded as cropped portions of the image. How the image data from previous frames is treated is called the 'disposal method'.
When GifImagePlugin reads
disposal_method
, it sets up what should happen to this frame's image data and then uses that when seeking to the next frame - in short, the currentdisposal_method
is not something that affects the appearance of this frame, but the next one.Which is why this
Pillow/src/PIL/GifImagePlugin.py
Lines 299 to 304 in ce3d80e
is incorrect. This PR changes
load_end
to use the previousdisposal_method
, instead of the current one.I've added a test case. The second frame of 'Tests/images/dispose_none_load_end.gif' is tested to equal 'Tests/images/dispose_none_load_end_second.gif'. You can verify this should be case by just opening up 'Tests/images/dispose_none_load_end.gif' in an image viewer.