[Image-SIG] PIL / wxPython conflict

Jeff Epler jepler at unpythonic.net
Wed Jun 29 14:20:38 CEST 2005

Are you sure that 'bitmaps/image.png' is not an invalid image file?

I damaged a PNG file and got this result while trying to .tostring() it:

>>> img = Image.open("broken.png")
>>> img = img.tostring()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/PIL/Image.py", line 436, in tostring
    import tempfile
  File "/usr/lib/python2.3/site-packages/PIL/ImageFile.py", line 192, in load
    raise IOError("image file is truncated (%d bytes not processed)" % len(b))
IOError: unknown error when reading image file

Image.open() does not fully load the image, it just looks at headers to
find such information as the resolution of the image.  The full image is
loaded when .load() is called explicitly, or some other method is called
that requires the image be loaded.  Therefore, it is no surprise that a
damaged image might open() but give an exception later the first time
the image data is used.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.python.org/pipermail/image-sig/attachments/20050629/018112ca/attachment.pgp

More information about the Image-SIG mailing list