[Image-SIG] png file example that breaks ImageFile
Eddie Bishop
eddie.bishop at gmail.com
Thu Jun 9 17:08:16 CEST 2011
Hello,
The PNG file which I have uploaded to http://i.imgur.com/GpJs3.png doesn't
work as expected with the example code given for the ImageFile class found
at http://www.pythonware.com/library/pil/handbook/imagefile.htm . The docs
say that feed() may raise an IOError exception, but a zlib error is raised
instead. Note that this image does work fine if the whole file is passed to
feed() in one single call.
I have python 2.7.1, using PIL 1.1.7.
Here is the python shell output:
$ python2
Python 2.7.1 (r271:86832, Feb 21 2011, 01:28:26)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ImageFile
>>>
>>> fp =
open('/srv/media/media/albums/60/47/566e-1c9c-41ac-9914-b63724f01693/6047566e-1c9c-41ac-9914-b63724f01693.png',
"rb")
>>>
>>> p = ImageFile.Parser()
>>>
>>> while 1:
... s = fp.read(1024)
... if not s:
... break
... p.feed(s)
...
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/usr/lib/python2.7/site-packages/PIL/ImageFile.py", line 402, in
feed
im = Image.open(fp)
File "/usr/lib/python2.7/site-packages/PIL/Image.py", line 1965, in open
return factory(fp, filename)
File "/usr/lib/python2.7/site-packages/PIL/ImageFile.py", line 91, in
__init__
self._open()
File "/usr/lib/python2.7/site-packages/PIL/PngImagePlugin.py", line 331,
in _open
s = self.png.call(cid, pos, len)
File "/usr/lib/python2.7/site-packages/PIL/PngImagePlugin.py", line 115,
in call
return getattr(self, "chunk_" + cid)(pos, len)
File "/usr/lib/python2.7/site-packages/PIL/PngImagePlugin.py", line 296,
in chunk_zTXt
self.im_info[k] = self.im_text[k] = zlib.decompress(v[1:])
zlib.error: Error -5 while decompressing data: incomplete or truncated
stream
-Eddie Bishop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20110609/2ff5720c/attachment.html>
More information about the Image-SIG
mailing list