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

images2gif.py handles palettes incorrectly. #81

Closed
GoogleCodeExporter opened this issue Sep 1, 2015 · 9 comments
Closed

images2gif.py handles palettes incorrectly. #81

GoogleCodeExporter opened this issue Sep 1, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

I'm using the release version of Pillow, the active development branch of PIL, 
with images2gif.py.

There are three issues here.

First, please see 
https://code.google.com/p/visvis/source/browse/vvmovie/images2gif.py#413

> palette = getheader(im)[1]

In personal communication with wiredfool from the PIL, we looked through the 
PIL code and established that the palette is in fact in getheader(im)[0][-1]


Second, the fallback palette is, from 
https://code.google.com/p/visvis/source/browse/vvmovie/images2gif.py#415

> palette = PIL.ImagePalette.ImageColor

But this is a module, and not appropriate for a color palette!

The correct solution would be to use PIL.Image.convert(mode='P') to convert the 
image to palette mode.  My client code converts everything to mode='P' already 
so I didn't test this.


Finally, there are .encode('utf-8') calls scattered around the code.  These 
won't work - the data given to you by PIL is already in bytes format.  Just 
deleting them seems to be effective.

With those changes, I was able to get this routine to write nice-looking 
animated GIFs!

Original issue reported on code.google.com by tom.ritc...@gmail.com on 24 Feb 2014 at 11:10

@vic1309
Copy link

vic1309 commented Mar 2, 2016

Guys, I'm still having the problem of:

TypeError: must be string or buffer, not None

Here is my code:

from PIL import Image, ImageSequence
import glob
from images2gif import writeGif
import numpy as np

a = np.sort(glob.glob(r'C:\User\lalala\anim*.bmp'))
images = [Image.open(fn) for fn in a]
writeGif('teste.gif',images,duration=0.2)

@almarklein
Copy link
Owner

@vic1309 what images2gif is that? The one from visvis or the one linked above? Have you tried imageio yet. It's much more stable since I mentioned it earlier in this thread.

@almarklein
Copy link
Owner

almarklein commented May 30, 2017

Closing. Please use imageio instead, and report any problems in https://github.com/imageio/imageio/issues

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

No branches or pull requests

3 participants