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

Extract frames from animated gif, every frame is not correct except the first frame when I save it to png file #1692

Closed
cflyt opened this issue Jan 29, 2016 · 7 comments · Fixed by #5857

Comments

@cflyt
Copy link

cflyt commented Jan 29, 2016

I want to extract frames from an animated gif image, and save every frame into png format, but i found the png is not correct in some area except the first frame.

   im = Image.open('earth.gif')
   try:
        while True:
            new_frame = im.convert('RGBA')
            new_frame.save('foo%02d.png' % im.tell(), 'PNG')
            im.seek(im.tell()+1)
    except EOFError:
        pass

This is origin image
earth.gif
earth

This is the second frame which i use my program got.
foo01

And the second frame shoud be(correct one):
image

the different area(red mark) between them:
diff

other frames has the same problem, is it a bug in GifImagePlugin.py?
Tell me what i should do ?

@radarhere
Copy link
Member

While I can't say for certain, I suspect that this is related to #1525

@radarhere
Copy link
Member

Is the animated GIF that you have provided one that could be used as a test image and subsequently released under Pillow's license?

@cflyt
Copy link
Author

cflyt commented Jan 31, 2016

While I can't say for certain, I suspect that this is related to #1525

I use the patch you provided in #1525, it does't work。And it throws exception:

palette_bytes = im.im.getpalette("RGB")[:palette_byte_number]
ValueError: image has no palette

@cflyt
Copy link
Author

cflyt commented Jan 31, 2016

@radarhere
Copy link
Member

Thanks for the link. The licensing for that file can be found at https://commons.wikimedia.org/wiki/File:Rotating_earth_(large).gif#Licensing

@radarhere radarhere changed the title extract frames from animated gif,every frame is not correct except the first frame when i save it to png file extract frames from animated gif, every frame is not correct except the first frame when i save it to png file Feb 1, 2016
@ritu1337
Copy link

@wiredfool wiredfool added the GIF label Mar 14, 2016
@radarhere radarhere changed the title extract frames from animated gif, every frame is not correct except the first frame when i save it to png file Extract frames from animated gif, every frame is not correct except the first frame when I save it to png file Feb 17, 2018
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to Icebox in Pillow May 11, 2019
@radarhere
Copy link
Member

I've created PR #5857 to resolve this.

second

Pillow automation moved this from Icebox to Closed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

4 participants