[Image-SIG] What's wrong with this TIF ... IOError("cannot identify image file")

image-sig at richardshea.fastmail.fm image-sig at richardshea.fastmail.fm
Mon Nov 30 10:17:50 CET 2009


Hi - I have a TIF which when I am try to read it with PIL I get
'IOError("cannot identify image file")'.

In it's original form PIL can read it. I then use ImageMagick to change
it's colour managment from RGB to CMYK (script A at bottom of email
shows the windows BAT files used). At that stage PIL won't read the
output. The output of TIFFDUMP applied to that image
(ZENDGraphOutput-Step1.TIF) is shown below.

However I read in an earlier post
(http://mail.python.org/pipermail/image-sig/2008-November/005263.html)
that some TIF headers are needed by PIL which are sometimes lost by
intermediate process so I used ImageMagick and TIFFSET to put them back
in place (script B at bottom of email). Unfortunately even after that
PIL won't read it. The output of TIFFDUMP applied to that image
(ZENDGraphOutput-Step2.TIF) is also shown below.

Is there anyone out there who can see why PIL is choking on this TIF ? I
would be grateful for any advice.

TIFFDUMP OUTPUT FOR THE FIRST FILE 
==================================
C:\20091130>C:\bin\installed\GnuWin32\bin\tiffdump.exe
"C:\20091130\OutputImages\ZENDGraphOutput-Step1.TIF"
C:\20091130\OutputImages\ZENDGraphOutput-Step1.TIF:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 374842 (0x5b83a) next 0 (0)
ImageWidth (256) SHORT (3) 1<1600>
ImageLength (257) SHORT (3) 1<981>
BitsPerSample (258) SHORT (3) 5<8 8 8 8 8>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<5>
FillOrder (266) SHORT (3) 1<1>
DocumentName (269) ASCII (2) 84<C:\usr\obfuscated ...>
StripOffsets (273) LONG (4) 981<8 327 646 965 1284 1603 1922 2241 2560
2879 3198 3517 3836 4155 4474 4793 5112 5431 5750 6069 6388 6707 7026
7345 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<5>
RowsPerStrip (278) SHORT (3) 1<1>
StripByteCounts (279) LONG (4) 981<319 319 319 319 319 319 319 319 319
319 319 319 319 319 319 319 319 319 319 319 319 319 319 319 ...>
XResolution (282) RATIONAL (5) 1<96>
YResolution (283) RATIONAL (5) 1<96>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
Software (305) ASCII (2) 58<ImageMagick 6.3.4 05/11/ ...>
InkSet (332) SHORT (3) 1<1>
ExtraSamples (338) SHORT (3) 1<2>

TIFFDUMP OUTPUT FOR THE SECOND FILE 
===================================
C:\20091130>C:\bin\installed\GnuWin32\bin\tiffdump.exe
"C:\20091130\OutputImages\ZENDGraphOutput-Step2.TIF"
C:\20091130\OutputImages\ZENDGraphOutput-Step2.TIF:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 309338 (0x4b85a) next 0 (0)
ImageWidth (256) SHORT (3) 1<1600>
ImageLength (257) SHORT (3) 1<981>
BitsPerSample (258) SHORT (3) 4<16 16 16 16>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<5>
FillOrder (266) SHORT (3) 1<1>
DocumentName (269) ASCII (2) 84<C:\usr\obfuscated ...>
StripOffsets (273) LONG (4) 981<8 191 374 557 740 923 1106 1289 1472
1655 1838 2021 2204 2387 2570 2753 2936 3119 3302 3485 3668 3851 4034
4217 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<4>
RowsPerStrip (278) SHORT (3) 1<1>
StripByteCounts (279) LONG (4) 981<183 183 183 183 183 183 183 183 183
183 183 183 183 183 183 183 183 183 183 183 183 183 183 183 ...>
XResolution (282) RATIONAL (5) 1<96>
YResolution (283) RATIONAL (5) 1<96>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
Software (305) ASCII (2) 7<Banana\0>
InkSet (332) SHORT (3) 1<1>






SCRIPT A
========
@echo off
set ICCCOLPROFDIR=C:\Adobe_ICC_Profiles_bundler
set IMGINPUTDIR=C:\20091130
set IMGOUTPUTDIR=C:\20091130\OutputImages
set CONVERTEXE=C:\ImageMagick\convert.exe
@echo off
REM Convert the TIFF Produced directly from the ZendGraph output
set INPUTFILE=ZENDGraphOutput.TIFF
set OUTPUTFILE=ZENDGraphOutput-Step1.TIF
@echo on 
%CONVERTEXE% %IMGINPUTDIR%\%INPUTFILE% +profile icc -profile
%ICCCOLPROFDIR%\RGBProfiles\AdobeRGB1998.icc -profile
%ICCCOLPROFDIR%\CMYKProfiles\USWebCoatedSWOP.icc -strip 
%IMGOUTPUTDIR%\%OUTPUTFILE%
@echo off

SCRIPT B
========
@echo off
set CONVERTEXE=C:\ImageMagick\convert.exe
set IMGDIR=C:\20091130\OutputImages
set TIFFSETEXE=C:\bin\installed\GnuWin32\bin\tiffset.exe
@echo off
REM Convert the TIFF Produced directly from the ZendGraph output
set INPUTFILE=ZENDGraphOutput-Step1.TIF
set INTERMEDIATEFILE=ZENDGraphOutput-Step2.TIF
@echo on 
%CONVERTEXE%  %IMGDIR%\%INPUTFILE%  -flatten +matte
%IMGDIR%\%INTERMEDIATEFILE%
@echo off
%TIFFSETEXE% -s 305 Banana %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 296 2   %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 282 96  %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 283 96  %IMGDIR%\%INTERMEDIATEFILE% 
@echo off


More information about the Image-SIG mailing list