[Image-SIG] PIL1.1.2 GIF handling error
Sun, 20 Jan 2002 14:33:52 +1100
I get an error when I use a gif file with PIL.
No problem with the same gif converted to png
Does anyone know how to get GIFs working in PIL 1.1.2?
(ie. their seems to be a problem with GifImagePlugin.py)
The GIF was generated by Microsoft Word 2000 when it saved the page as a web
page and produced a gif for the image on the word page.
Same fault happens under Python 2.1 or 2.2
The following is some of the Traceback FYI
img1 = PIL_Image.open(filename)
File "C:\Python21\lib\PIL\Image.py", line 945, in open
return factory(fp, filename)
File "C:\Python21\lib\PIL\ImageFile.py", line 69, in __init__
File "C:\Python21\lib\PIL\GifImagePlugin.py", line 85, in _open
self.seek(0) # get ready to read first frame
File "C:\Python21\lib\PIL\GifImagePlugin.py", line 108, in seek
self.palette = self.global_palette
AttributeError: GifImageFile instance has no attribute 'global_palette'
Greg> I get an error when I use a gif file with PIL. No problem with
Greg> the same gif converted to png
Greg> File "C:\Python21\lib\PIL\GifImagePlugin.py", line 108, in seek
Greg> self.palette = self.global_palette
Greg> AttributeError: GifImageFile instance has no attribute
It appears your GIF image doesn't have all the properties the PIL code is
expecting. In the code for _open it only sets self.global_palette under
if flags & 128:
# get global palette
self.info["background"] = ord(s)
self.global_palette = self.palette =\
but the code in seek() (which is always called), expects a global palette to
always be present, so it looks like a bug in PIL's handling of GIF images.
According to the PIL webpage, you can send questions about PIL to
Skip Montanaro (firstname.lastname@example.org - http://www.mojam.com/)