Gareth wrote:
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()
p.feed(file.read())
img = p.close()
file.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:
TypeError: 'NoneType' object is unsubscriptable
sure looks like a bug to me. as a workaround, try changing the "except
IOError:" line in this section of ImageFile.py
# attempt to open this file
try:
try:
fp = _ParserFile(self.data)
im = Image.open(fp)
finally:
fp.close() # explicitly close the virtual file
except IOError: # <-- this line
pass # not enough data
to
except (IOError, TypeError):
also, if you can, mail me a copy of the offending file (or post it
somewhere and send me an URL) so I can investigate further.
</F>
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig