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

Animated GIF Losing-Palette Issue #312

Closed
maxattack opened this issue Jul 31, 2013 · 10 comments

Comments

Projects
None yet
5 participants
@maxattack
Copy link

commented Jul 31, 2013

Some animated gifs lose palette information after the first frame. Workaround exists here: http://stackoverflow.com/questions/4904940/python-converting-gif-frames-to-png

@aclark4life

This comment has been minimized.

Copy link
Member

commented Jul 31, 2013

Thanks, can you submit a pull request? And/or maybe the fix-author will, I've just added a comment there.

@d-schmidt

This comment has been minimized.

Copy link
Contributor

commented Jul 31, 2013

The so link is two years old. Is this still a problem? I will check this out later today.

@aclark4life

This comment has been minimized.

Copy link
Member

commented Jul 31, 2013

@d-schmidt 2 years is young in the land of PIL fixes. We recently fixed a 10 year old bug.

@lebek

This comment has been minimized.

Copy link

commented Jul 31, 2013

Fix author here - I'll try to put together a pull request sometime this week.

@aclark4life

This comment has been minimized.

Copy link
Member

commented Jul 31, 2013

Thanks @lebek

@d-schmidt

This comment has been minimized.

Copy link
Contributor

commented Jul 31, 2013

Okay lets shed some light on this "issue":

from PIL import Image

im = Image.open('testbilder_july/Fighter-Front.gif')
transparency = im.info['transparency'] 
#im.save('test1.png', transparency=transparency)

im.seek(im.tell()+1)
transparency = im.info['transparency']
im.save('test2.png',"PNG", transparency=transparency)

will work already. The palette gets lost while saving and not while seeking.

from PIL import Image

im = Image.open('testbilder_july/Fighter-Front.gif')
transparency = im.info['transparency'] 
p = im.palette.getdata()[1]
im.save('test1.png',"PNG", transparency=transparency)
im.seek(im.tell()+1)
im.putpalette(p)
transparency = im.info['transparency']
im.save('test2.png',"PNG", transparency=transparency)

this does work too.

Now I'm fixing the source of the problem and we are no longer circling around it. I've found the problem in gif, it simply ignors/overwrites the internal palette while saving. You have to add it via parameter.
Now I'm looking into png.

edit: Copying the whole palette does work and I already know why, I just want to know why it breaks in the first place.

@d-schmidt

This comment has been minimized.

Copy link
Contributor

commented Aug 2, 2013

Not perfect yet, will send a pull on Monday.

@d-schmidt

This comment has been minimized.

Copy link
Contributor

commented Aug 6, 2013

Sent.

aclark4life added a commit that referenced this issue Aug 22, 2013

Merge pull request #315 from d-schmidt/master
fix Issue #312 + gif optimize improvement
@d-schmidt

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2013

autoclose didn't work, you can close this

@bpeck

This comment has been minimized.

Copy link

commented Apr 18, 2014

I am still getting this issue on OSX 10.9 after cloning and building latest from github last night. I have an animated GIF that displays correctly in my web browser and in Finder's preview, but if I load the GIF into an Image and call show() on any frame besides the first one, I get a corrupted image.

I tried the workaround posted earlier in this thread, and that doesn't seem to help either. Any advice? Thanks! Below is a minimal test case:

in the following test code, I am using
https://dl.dropboxusercontent.com/u/14459075/test.gif
as my test.gif

import PIL
import PIL.Image
i = PIL.Image.open('test.gif')
i.show() # correct image displays
i.seek(i.tell() + 1)
i.show() # image is incorrect

screen shot 2014-04-17 at 9 45 57 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.