[Image-SIG] Re: Setting TITT Attributes when saving

Fredrik Lundh fredrik at pythonware.com
Tue Feb 22 17:00:05 CET 2005

Michael Bierenfeld wrote:

> I have just joined the list .. so nice greetings to all :
> The following code :
> fp = open (pgmpfile)                  # 8 Bit pgm File
> imagecontent = fp.read ()
> fp.close ()
> parser = ImageFile.Parser ()
> parser.feed (imagecontent)
> image = parser.close ()

(umm.  what's wrong with using "image = Image.open(pgmpfile)" ?)

> image.save (tifffile)
> Stores a PGM-File as a TIFF-File. The File should be further processed
> by pytiff. But this packages throws the following Exception while executing
> reader = pytiff.TiffReader (tifffile)
> ValueError: TIFF image doesn't have a samples per pixel tag.

Looks like someone didn't read the TIFF specification.  The "samples per pixels"
tag (tag 277) defaults to 1 in all versions of the specification, and is only required
for images that consist of multiple bands (such as RGB and RGBA).

The pytiff library should be fixed to use proper defaults for "missing" fields (see
appendix A in the TIFF specification for details).


More information about the Image-SIG mailing list