Skip to content
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

Use previous disposal method in GIF load_end #5125

Merged
merged 1 commit into from Dec 29, 2020

Conversation

radarhere
Copy link
Member

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 current disposal_method is not something that affects the appearance of this frame, but the next one.

Which is why this

def load_end(self):
ImageFile.ImageFile.load_end(self)
# if the disposal method is 'do not dispose', transparent
# pixels should show the content of the previous frame
if self._prev_im and self.disposal_method == 1:

is incorrect. This PR changes load_end to use the previous disposal_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Last frame of gif has second last frame merged to it
2 participants