[Image-SIG] is this a bug?

Gareth gareth at spacetaken.net
Tue Sep 2 13:48:33 CEST 2008

I believe I have found a bug with PIL. It can be illustrated by the 
following code:

from PIL import Image, ImageFile

path = <path to a valid png file>

file = open(path, 'rb')
p = ImageFile.Parser()
img = p.close()

img.thumbnail((380, 380), Image.ANTIALIAS)
img.save(<path in an existing directory>)

- this works fine it the path is not to a png but to a jpg or gif, but 
given that is points to a (valid) png it chucks the following error:

Traceback (most recent call last):
  File "piltest.py", line 12, in <module>
    img.save('C:/Documents and Settings/gareth0/Desktop/thumb.png')
  File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1372, in save
  File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 189, in load
    s = read(self.decodermaxblock)
  File "C:\Python25\Lib\site-packages\PIL\PngImagePlugin.py", line 365, 
in load_read
    return self.fp.read(bytes)
  File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 300, in read
    data = self.data[pos:pos+bytes]
TypeError: 'NoneType' object is unsubscriptable

- i hope someone can help me out here, this has been driving me insane, 

More information about the Image-SIG mailing list