[Image-SIG] PIL not loading some TIFF files?

Green Bryan - bgreen Bryan.Green at acxiom.com
Wed Nov 5 00:18:20 CET 2008


It appears that the problem has to do with the following tags not being
set in the image.  I set these with the tiffset program and PIL then
loaded the image without any trouble.  I do not know how to set these
tags in PIL.  Maybe someone has a suggestion?  Also, if you open the
file in GIMP and save the problem is fixed.  I understand this is not a
solution for you-- just making note.  

Most viewers follow fairly closely to the tif spec (they also try and do
the "right thing" for non-standard software)-- PIL is not so forgiving.
If needed you could write a script to fix the tags on the fly using the
command line tiffset program.  It is fast.
 
XResolution (282) RATIONAL (5) 1<72> 
YResolution (283) RATIONAL (5) 1<72> 
ResolutionUnit (296) SHORT (3) 1<2>


-----Original Message-----
From: image-sig-bounces+bryan.green=acxiom.com at python.org
[mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf
Of Green Bryan - bgreen
Sent: Tuesday, November 04, 2008 4:52 PM
To: B. Bogart; image-sig at python.org
Subject: Re: [Image-SIG] PIL not loading some TIFF files?

There are some differences between the two.  Mask.tif claims to have
been created by the GIMP and has a bps of 3 8-bit values.
Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit
values.


c:\store-00000.tif:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 1228808 (0x12c008) next 0 (0)
ImageWidth (256) SHORT (3) 1<640>
ImageLength (257) SHORT (3) 1<480>
BitsPerSample (258) SHORT (3) 4<8 8 8 8>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1<8>
SamplesPerPixel (277) SHORT (3) 1<4>
StripByteCounts (279) LONG (4) 1<1228800>
PlanarConfig (284) SHORT (3) 1<1>
Software (305) ASCII (2) 7<PD/GEM\0>

c:\mask.tif:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 921608 (0xe1008) next 0 (0)
SubFileType (254) LONG (4) 1<0>
ImageWidth (256) SHORT (3) 1<640>
ImageLength (257) SHORT (3) 1<480>
BitsPerSample (258) SHORT (3) 3<8 8 8>
Compression (259) SHORT (3) 1<1>
Photometric (262) SHORT (3) 1<2>
DocumentName (269) ASCII (2) 66</home/bbogart/Projects/i ...>
ImageDescription (270) ASCII (2) 22<Created with The GIMP\0>
StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408
737288 860168>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) SHORT (3) 1<64>
StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880
122880 122880 61440>
XResolution (282) RATIONAL (5) 1<72>
YResolution (283) RATIONAL (5) 1<72>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>

-----Original Message-----
From: image-sig-bounces+bryan.green=acxiom.com at python.org
[mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf
Of B. Bogart
Sent: Tuesday, November 04, 2008 4:14 PM
To: image-sig at python.org
Subject: [Image-SIG] PIL not loading some TIFF files?

Hello all,

I'm unable to get PIL (Image.open) to load certain TIFF files generated
by another application (using libtiff).

According to imageMagick the files are the same type:

mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb
store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb

mask.tif loads fine:

>>> image = Image.open("mask.tif")
>>>

but store-00000.tif fails:

>>> image = Image.open("store-00000.tif")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in
open
    raise IOError("cannot identify image file")
IOError: cannot identify image file
>>>

I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy.

You can grab these two files from:

http://www.ekran.org/ben/tmp/mask.tif
http://www.ekran.org/ben/tmp/store-00000.tif

This is a problem because it is files created by this very application I
need to be able to read with PIL. Converting them is not practical
because there will be at least 900 images and processing time is an
issue.

Thanks,
B. Bogart
_______________________________________________
Image-SIG maillist  -  Image-SIG at python.org
http://mail.python.org/mailman/listinfo/image-sig
************************************************************************
*
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be
legally privileged.

If the reader of this message is not the intended recipient, you are 
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank you.
************************************************************************
*

_______________________________________________
Image-SIG maillist  -  Image-SIG at python.org
http://mail.python.org/mailman/listinfo/image-sig


More information about the Image-SIG mailing list