[Image-SIG] Does PIL not handle TIFFs created on Mac OS X?

Tom Bridgman bridgman at wyeth.gsfc.nasa.gov
Wed Sep 17 14:09:50 EDT 2003


Rob Managan wrote:
> 
> At 12:31 PM +0200 9/17/03, Dinu Gherman wrote:
> >Hi,
> >
> >has anybody succeeded here in using PIL for loading TIFFs generated
> >on OS X, e.g. stuff like the attached little sample file? I'm using
> >PIL 1.1.4, but get errors like the following:
> >
> >   >>> import Image
> >   >>> tiff = Image.open("test.tiff")
> >   Traceback (most recent call last):
> >     File "<stdin>", line 1, in ?
> >     File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 1571, in open
> >       raise IOError("cannot identify image file")
> >   IOError: cannot identify image file
> >
> If you add the line
> Image.DEBUG = 1 after the import you get this information
> tag: ImageWidth (256) - type: short (3) - value: (55,)
> tag: ImageLength (257) - type: short (3) - value: (43,)
> tag: BitsPerSample (258) - type: short (3) - value: (8, 8, 8, 8)
> tag: Compression (259) - type: short (3) - value: (1,)
> tag: PhotometricInterpretation (262) - type: short (3) - value: (2,)
> tag: StripOffsets (273) - type: long (4) - value: (8,)
> tag: SamplesPerPixel (277) - type: short (3) - value: (4,)
> tag: StripByteCounts (279) - type: long (4) - value: (9460,)
> tag: XResolution (282) - type: rational (5) - value: ((720000, 10000),)
> tag: YResolution (283) - type: rational (5) - value: ((720000, 10000),)
> tag: PlanarConfiguration (284) - type: short (3) - value: (1,)
> tag: ResolutionUnit (296) - type: short (3) - value: (2,)
> tag: ExtraSamples (338) - type: short (3) - value: (1,)
> *** Summary ***
> - compression: raw
> - photometric_interpretation: 2
> - planar_configuration: 1
> - size: (55, 43)
> format key: (2, 1, (8, 8, 8, 8), (1,))
> - unsupported format
> tag: ImageWidth (256) - type: short (3) - value: (55,)
> tag: ImageLength (257) - type: short (3) - value: (43,)
> tag: BitsPerSample (258) - type: short (3) - value: (8, 8, 8, 8)
> tag: Compression (259) - type: short (3) - value: (1,)
> tag: PhotometricInterpretation (262) - type: short (3) - value: (2,)
> tag: StripOffsets (273) - type: long (4) - value: (8,)
> tag: SamplesPerPixel (277) - type: short (3) - value: (4,)
> tag: StripByteCounts (279) - type: long (4) - value: (9460,)
> tag: XResolution (282) - type: rational (5) - value: ((720000, 10000),)
> tag: YResolution (283) - type: rational (5) - value: ((720000, 10000),)
> tag: PlanarConfiguration (284) - type: short (3) - value: (1,)
> tag: ResolutionUnit (296) - type: short (3) - value: (2,)
> tag: ExtraSamples (338) - type: short (3) - value: (1,)
> *** Summary ***
> - compression: raw
> - photometric_interpretation: 2
> - planar_configuration: 1
> - size: (55, 43)
> format key: (2, 1, (8, 8, 8, 8), (1,))
> - unsupported format
> 
> In the IDE I found that the problem originates in
> PIL/TiffImagePlugin.py line 510
> 
> The closest format keys are
> (2, 1, (8, 8, 8, 8), (0,)) ('RGBX','(RGBX)')
> (2, 1, (8, 8, 8, 8), (2,)) ('RGBA','(RGBA)')
> 
> I tired adding (2, 1, (8, 8, 8, 8), (1,)) ('RGBX','(RGBX)')
> but I haven't succeeded in getting the change to be used yet. Must be
> doing it in the wrong place.
> --

Try "RGBA" instead of "RBGX" since the extra is an alpha-channel.  That
worked per my earlier comments.

Tom
--
Dr. William T."Tom" Bridgman           Scientific Visualization Studio
Global Science & Technology, Inc.      NASA/Goddard Space Flight Center
Email: bridgman at wyeth.gsfc.nasa.gov    Code 935
Phone: 301-286-1346                    Greenbelt, MD 20771
FAX:   TBD                             http://svs.gsfc.nasa.gov/



More information about the Image-SIG mailing list