[Image-SIG] error on the first copy(), but not the second

Sébastien Barthélemy barthelemy at crans.org
Wed Jul 7 17:25:06 CEST 2010


Hello,

I got a picture refused as erroneous on photobox (an online printing
service). As I can open the picture without a problem using preview on
my mac, I decided to further investigate the problem with PIL and
ImageMagick.

ImageMagick successfully displays the picture but prints the following
error message, indicating my picture is indeed corrupted:

$ display IMG_1818.JPG
display: Unsupported marker type 0x19 `IMG_1818.JPG' @
error/jpeg.c/EmitMessage/235.

PIL fails to read the picture the first time, but succeed the second
one! The picture can then be displayed with show().

$ python
Python 2.6.5 (r265:79063, Jul  6 2010, 17:00:38)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> im = Image.open('IMG_1818.JPG')
>>> im.copy()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py",
line 743, in copy
    self.load()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py",
line 215, in load
    raise_ioerror(e)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py",
line 52, in raise_ioerror
    raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file
>>> im.copy()
<Image.Image image mode=RGB size=3264x2448 at 0x100766EF0>

I thought you might be interested to know about it. Does anyone have
an explanation? I use Mac Os 10.6, with PIL 1.1.7 provided by
macports.

$ otool -L ./Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
./Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so:
    /opt/local/lib/libjpeg.8.dylib (compatibility version 9.0.0,
current version 9.1.0)
    /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current
version 1.2.5)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 125.0.1)


Regards.


More information about the Image-SIG mailing list