[Image-SIG] problem with PIL's Image.save() on TIFFs

Guy K. Kloss G.Kloss at massey.ac.nz
Wed Feb 27 23:40:39 CET 2008


I've just had some problems with PIL's implementation of the Image.save() 
method when writing TIFF files. Apparently some internal tags on resolution 
are totally out of the normal. Using the TIFFs from libtiff later on produces 
some warning on a tag with bad information.

This is what libtiff's warning handler produces:

_TIFFVSetField: diag.tif: Bad value 47088 for "ResolutionUnit".
diag.tif: Warning, "YResolution": Information lost writing value 
(-2.94176e-05) as (unsigned) RATIONAL.

According to Graeme Gill's information (who implements Argyll CMS, that's 
using libtiff for its purposes)

[...] According to the TIFF spec, the ResolutionUnit tag can have one of three
values: (From tiff/libtiff/tiff.h)

#define TIFFTAG_RESOLUTIONUNIT      296 /* units of resolutions */
#define     RESUNIT_NONE        1   /* no meaningful units */
#define     RESUNIT_INCH        2   /* english */
#define     RESUNIT_CENTIMETER      3   /* metric */

It seems like the implementation in PIL.Image for save() puts a non standard 
value (here 47088) into the field ResolutionUnit, and there also seems to be 
something funny with the YResolution field in the TIFF file.

To me this very much sounds like an issue with uninitialised variables in some 
structures, as the values tend to be different on different runs, as well as 
the fact that they're well out of whack indicates this.


Guy K. Kloss
Institute of Information and Mathematical Sciences
Te Kura Putaiao o Mohiohio me Pangarau
Room 2.63, Quad Block A Building
Massey University, Auckland, Albany
Private Bag 102 904, North Shore Mail Centre
voice: +64 9 414-0800 ext. 9585   fax: +64 9 441-8181
eMail: G.Kloss at massey.ac.nz  http://www.massey.ac.nz/~gkloss/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://mail.python.org/pipermail/image-sig/attachments/20080228/492a85bb/attachment.pgp 

More information about the Image-SIG mailing list