python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.27k stars 2.23k forks source link

Overlapping frames in animated GIF and PNG #5032

Closed doublex closed 3 years ago

doublex commented 4 years ago

This image: AnimGif

Testcase (frame is interleaved - tested with PIL7 and PIL8):

import PIL.Image
imageObject = PIL.Image.open("/tmp/98246874-2e18a800-1f73-11eb-8583-f2c1f7d293f0.gif")
imageObject.seek(5)
imageObject.seek(6)
imageObject.seek(7)
imageObject.show() 
doublex commented 4 years ago

Expected result: test-7

PIL frame: 7

doublex commented 4 years ago

Also APNG images won't load properly: ezgif-3-74c50ea21b65

radarhere commented 4 years ago

For the record, the animated PNG you have just attached shows this when the code from your first post is run.

png

doublex commented 4 years ago

Yes, there are bugs decoding AnimGIFs and APNGs (GIF is nastier). imagemagick decodes the frame to: xx-7

stevemcgf commented 3 years ago

I only see the issue with APNG files not with GIF.

stevemcgf commented 3 years ago

Animated PNG sticker02

Incorrect render of 2nd frame tmpmvjf3dp4

Fixed render of 2nd frame (using code in pull request) tmp1l63_0g8

doublex commented 3 years ago

@stevemcgf

AnimGIF renders wrong (at least for me using pillow 8.0.1). Steps to reproduce:

wget https://user-images.githubusercontent.com/274624/98246874-2e18a800-1f73-11eb-8583-f2c1f7d293f0.gif
import PIL.Image
image = PIL.Image.open("/tmp/98246874-2e18a800-1f73-11eb-8583-f2c1f7d293f0.gif")
for frame in PIL.ImageSequence.Iterator(image):
    last_frame = frame
last_frame.show()
radarhere commented 3 years ago

The GIF part of this should be resolved by #5125

radarhere commented 3 years ago

I've created PR #5126 to resolve the APNG part of this, as an alternative to #5071

radarhere commented 3 years ago

The GIF part of this should be fixed in Pillow 8.1.0, due to be released on January 2.

doublex commented 3 years ago

Thanks for the effort!

radarhere commented 3 years ago

The APNG part of this should now also be fixed in Pillow 8.1.0

doublex commented 3 years ago

@radarhere Thanks again for your efforts!