Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: RE: 32-bit TIFFs and PIL
From: Mark Rivers <rivers@cars.uchicago.edu>
To: "'J. Lewis Muir'" <jlmuir@imca-cat.org>
Cc: "dvine@aps.anl.gov" <dvine@aps.anl.gov>, Timothy Madden <tmadden@aps.anl.gov>, Ross Harder <rharder@aps.anl.gov>, "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Tue, 20 Mar 2012 19:34:33 +0000
Hi Lewis,

Thanks very much for tracking that down!

I have added the SampleFormat tag to the areaDetector TIFF files, and now I can read signed 32-bit integer TIFFs with PIL.  It will not read unsigned 32-bit TIFFs.  By adding the SampleFormat tag I can now also successfully write 32-bit float and 64-bit double TIFF files as well.  Those can be read fine with IDL, and the 32-bit float files can also be read by PIL.

I will do testing with each areaDetector data type and report which applications (IDL, ImageJ, PIL) can read which data types.

Thanks again,
Mark



-----Original Message-----
From: J. Lewis Muir [mailto:jlmuir@imca-cat.org] 
Sent: Tuesday, March 20, 2012 11:48 AM
To: Mark Rivers
Cc: Timothy Madden; dvine@aps.anl.gov; Ross Harder; tech-talk@aps.anl.gov
Subject: Re: 32-bit TIFFs and PIL

On 3/20/12 11:25 AM, J. Lewis Muir wrote:
> So it seems to be unhappy about the pixel mode.

Looking further, there's a debug level variable in PIL which
sheds more light on things:

===
>>> import PIL.Image
>>> PIL.Image.DEBUG = 1
>>> im = PIL.Image.open("/tmp/im.tif")
tag: ImageWidth (256) - type: short (3) - value: (1023,)
tag: ImageLength (257) - type: short (3) - value: (1023,)
tag: BitsPerSample (258) - type: short (3) - value: (32,)
tag: Compression (259) - type: short (3) - value: (1,)
tag: PhotometricInterpretation (262) - type: short (3) - value: (1,)
tag: Make (271) - type: ascii (2) - value: Unknown
tag: Model (272) - type: ascii (2) - value: Unknown
tag: StripOffsets (273) - type: long (4) - value: (8,)
tag: SamplesPerPixel (277) - type: short (3) - value: (1,)
tag: RowsPerStrip (278) - type: short (3) - value: (1023,)
tag: StripByteCounts (279) - type: long (4) - value: (4186116,)
tag: PlanarConfiguration (284) - type: short (3) - value: (1,)
*** Summary ***
- compression: raw
- photometric_interpretation: 1
- planar_configuration: 1
- fill_order: 1
- size: (1023, 1023)
format key: ('II', 1, 1, 1, (32,), ())
- unsupported format
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/opt3/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py",
line 1980, in open
    raise IOError("cannot identify image file")
IOError: cannot identify image file
===

Looking at TiffImagePlugin.py where it generates the "-
unsupported format" message, and comparing the output with an
SLS PILATUS image that works, I see the following difference:

=== /tmp/im.tif (bad) ===
format key: ('II', 1, 1, 1, (32,), ())
===

=== /tmp/sls-im.tif (good) ===
format key: ('II', 1, 2, 1, (32,), ())
===

The third format key value is different.  Looking at
TiffImagePlugin.py shows that the third value is the value of
the SAMPLEFORMAT (339) tag.  In the bad TIFF, that tag appears
to be missing, but in the good TIFF, it's present and the debug
output shows it:

=== /tmp/sls-im.tif (good) ===
tag: SampleFormat (339) - type: short (3) - value: (2,)
===

Lewis


Replies:
RE: 32-bit TIFFs and PIL Mark Rivers
References:
32-bit TIFFs and PIL Mark Rivers
Re: 32-bit TIFFs and PIL J. Lewis Muir
Re: 32-bit TIFFs and PIL J. Lewis Muir

Navigate by Date:
Prev: Re: "Size of symbol changed" warnings building EPICS Base 3.14.12.2 Dirk Zimoch
Next: Re: menuFtype for 64 bit integers aka. long long and unsigned long long Andrew Johnson
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: Re: 32-bit TIFFs and PIL J. Lewis Muir
Next: RE: 32-bit TIFFs and PIL Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·