<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [Image-SIG] PIL not loading some TIFF files?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>They are required per the TIFF 6.0 baseline standard. Here is a link (and I pasted the relevant text from p.64):<BR>
<A HREF="http://www.alternatiff.com/resources/TIFF6.pdf">http://www.alternatiff.com/resources/TIFF6.pdf</A><BR>
<BR>
Required Fields for RGB Images<BR>
These are the required fields for RGB images (in numerical order):<BR>
TagName Decimal Hex Type Value<BR>
ImageWidth 256 100 SHORT or LONG<BR>
ImageLength 257 101 SHORT or LONG<BR>
BitsPerSample 258 102 SHORT 8,8,8<BR>
Compression 259 103 SHORT 1 or 32773<BR>
PhotometricInterpretation 262 106 SHORT 2<BR>
StripOffsets 273 111 SHORT or LONG<BR>
SamplesPerPixel 277 115 SHORT 3 or more<BR>
RowsPerStrip 278 116 SHORT or LONG<BR>
StripByteCounts 279 117 LONG or SHORT<BR>
XResolution 282 11A RATIONAL<BR>
YResolution 283 11B RATIONAL<BR>
ResolutionUnit 296 128 SHORT 1, 2 or 3<BR>
24<BR>
TIFF 6.0 Specification Final—June 3, 1992<BR>
The BitsPerSample values listed above apply only to the main image data. If<BR>
ExtraSamples are present, the appropriate BitsPerSample values for those<BR>
samples must also be included.<BR>
Baseline TIFF RGB images were called TIFF Class R images in earlier versions<BR>
of the TIFF specification.<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: B. Bogart [<A HREF="mailto:ben@ekran.org">mailto:ben@ekran.org</A>]<BR>
Sent: Tue 11/4/2008 6:06 PM<BR>
To: Green Bryan - bgreen<BR>
Cc: image-sig@python.org<BR>
Subject: Re: [Image-SIG] PIL not loading some TIFF files?<BR>
<BR>
Thanks for the details.<BR>
<BR>
I've passed this info onto the pd/Gem developers so they can add these<BR>
tags to all tifs written by the software.<BR>
<BR>
Are these tags required as part of the TIFF spec? Or are they just best<BR>
practise?<BR>
<BR>
Thanks again,<BR>
B. Bogart<BR>
<BR>
Green Bryan - bgreen wrote:<BR>
> It appears that the problem has to do with the following tags not being<BR>
> set in the image. I set these with the tiffset program and PIL then<BR>
> loaded the image without any trouble. I do not know how to set these<BR>
> tags in PIL. Maybe someone has a suggestion? Also, if you open the<BR>
> file in GIMP and save the problem is fixed. I understand this is not a<BR>
> solution for you-- just making note. <BR>
><BR>
> Most viewers follow fairly closely to the tif spec (they also try and do<BR>
> the "right thing" for non-standard software)-- PIL is not so forgiving.<BR>
> If needed you could write a script to fix the tags on the fly using the<BR>
> command line tiffset program. It is fast.<BR>
> <BR>
> XResolution (282) RATIONAL (5) 1<72><BR>
> YResolution (283) RATIONAL (5) 1<72><BR>
> ResolutionUnit (296) SHORT (3) 1<2><BR>
><BR>
><BR>
> -----Original Message-----<BR>
> From: image-sig-bounces+bryan.green=acxiom.com@python.org<BR>
> [<A HREF="mailto:image-sig-bounces+bryan.green=acxiom.com@python.org">mailto:image-sig-bounces+bryan.green=acxiom.com@python.org</A>] On Behalf<BR>
> Of Green Bryan - bgreen<BR>
> Sent: Tuesday, November 04, 2008 4:52 PM<BR>
> To: B. Bogart; image-sig@python.org<BR>
> Subject: Re: [Image-SIG] PIL not loading some TIFF files?<BR>
><BR>
> There are some differences between the two. Mask.tif claims to have<BR>
> been created by the GIMP and has a bps of 3 8-bit values.<BR>
> Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit<BR>
> values.<BR>
><BR>
><BR>
> c:\store-00000.tif:<BR>
> Magic: 0x4949 <little-endian> Version: 0x2a<BR>
> Directory 0: offset 1228808 (0x12c008) next 0 (0)<BR>
> ImageWidth (256) SHORT (3) 1<640><BR>
> ImageLength (257) SHORT (3) 1<480><BR>
> BitsPerSample (258) SHORT (3) 4<8 8 8 8><BR>
> Compression (259) SHORT (3) 1<1><BR>
> Photometric (262) SHORT (3) 1<2><BR>
> StripOffsets (273) LONG (4) 1<8><BR>
> SamplesPerPixel (277) SHORT (3) 1<4><BR>
> StripByteCounts (279) LONG (4) 1<1228800><BR>
> PlanarConfig (284) SHORT (3) 1<1><BR>
> Software (305) ASCII (2) 7<PD/GEM\0><BR>
><BR>
> c:\mask.tif:<BR>
> Magic: 0x4949 <little-endian> Version: 0x2a<BR>
> Directory 0: offset 921608 (0xe1008) next 0 (0)<BR>
> SubFileType (254) LONG (4) 1<0><BR>
> ImageWidth (256) SHORT (3) 1<640><BR>
> ImageLength (257) SHORT (3) 1<480><BR>
> BitsPerSample (258) SHORT (3) 3<8 8 8><BR>
> Compression (259) SHORT (3) 1<1><BR>
> Photometric (262) SHORT (3) 1<2><BR>
> DocumentName (269) ASCII (2) 66</home/bbogart/Projects/i ...><BR>
> ImageDescription (270) ASCII (2) 22<Created with The GIMP\0><BR>
> StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408<BR>
> 737288 860168><BR>
> Orientation (274) SHORT (3) 1<1><BR>
> SamplesPerPixel (277) SHORT (3) 1<3><BR>
> RowsPerStrip (278) SHORT (3) 1<64><BR>
> StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880<BR>
> 122880 122880 61440><BR>
> XResolution (282) RATIONAL (5) 1<72><BR>
> YResolution (283) RATIONAL (5) 1<72><BR>
> PlanarConfig (284) SHORT (3) 1<1><BR>
> ResolutionUnit (296) SHORT (3) 1<2><BR>
><BR>
> -----Original Message-----<BR>
> From: image-sig-bounces+bryan.green=acxiom.com@python.org<BR>
> [<A HREF="mailto:image-sig-bounces+bryan.green=acxiom.com@python.org">mailto:image-sig-bounces+bryan.green=acxiom.com@python.org</A>] On Behalf<BR>
> Of B. Bogart<BR>
> Sent: Tuesday, November 04, 2008 4:14 PM<BR>
> To: image-sig@python.org<BR>
> Subject: [Image-SIG] PIL not loading some TIFF files?<BR>
><BR>
> Hello all,<BR>
><BR>
> I'm unable to get PIL (Image.open) to load certain TIFF files generated<BR>
> by another application (using libtiff).<BR>
><BR>
> According to imageMagick the files are the same type:<BR>
><BR>
> mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb<BR>
> store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb<BR>
><BR>
> mask.tif loads fine:<BR>
><BR>
>>>> image = Image.open("mask.tif")<BR>
>>>><BR>
><BR>
> but store-00000.tif fails:<BR>
><BR>
>>>> image = Image.open("store-00000.tif")<BR>
> Traceback (most recent call last):<BR>
> File "<stdin>", line 1, in <module><BR>
> File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in<BR>
> open<BR>
> raise IOError("cannot identify image file")<BR>
> IOError: cannot identify image file<BR>
><BR>
> I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy.<BR>
><BR>
> You can grab these two files from:<BR>
><BR>
> <A HREF="http://www.ekran.org/ben/tmp/mask.tif">http://www.ekran.org/ben/tmp/mask.tif</A><BR>
> <A HREF="http://www.ekran.org/ben/tmp/store-00000.tif">http://www.ekran.org/ben/tmp/store-00000.tif</A><BR>
><BR>
> This is a problem because it is files created by this very application I<BR>
> need to be able to read with PIL. Converting them is not practical<BR>
> because there will be at least 900 images and processing time is an<BR>
> issue.<BR>
><BR>
> Thanks,<BR>
> B. Bogart<BR>
> _______________________________________________<BR>
> Image-SIG maillist - Image-SIG@python.org<BR>
> <A HREF="http://mail.python.org/mailman/listinfo/image-sig">http://mail.python.org/mailman/listinfo/image-sig</A><BR>
> ************************************************************************<BR>
> *<BR>
> The information contained in this communication is confidential, is<BR>
> intended only for the use of the recipient named above, and may be<BR>
> legally privileged.<BR>
><BR>
> If the reader of this message is not the intended recipient, you are<BR>
> hereby notified that any dissemination, distribution or copying of this<BR>
> communication is strictly prohibited.<BR>
><BR>
> If you have received this communication in error, please resend this<BR>
> communication to the sender and delete the original message or any copy<BR>
> of it from your computer system.<BR>
><BR>
> Thank you.<BR>
> ************************************************************************<BR>
> *<BR>
><BR>
> _______________________________________________<BR>
> Image-SIG maillist - Image-SIG@python.org<BR>
> <A HREF="http://mail.python.org/mailman/listinfo/image-sig">http://mail.python.org/mailman/listinfo/image-sig</A><BR>
><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>