[Image-SIG] Re: IOError: decoder group3 not available

Fredrik Lundh fredrik@pythonware.com
Tue, 22 Apr 2003 16:06:10 +0200


David Thibault wrote:

> I've got multipage TIFF files that I need to convert to PDF using PIL and
> reportlab.  I think I'd be all set except I seem to be hitting an old bug.
> I saw this:
> http://mail.python.org/pipermail/image-sig/2002-February/001736.html and it
> seems to be the exact problem I'm running into.  Has anyone ever figured
> this out?  These tiff's are mode 1 and I get the exact error in the subject
> line if I try to convert them to RGB or if I try to convert them to JPG.

PIL's TIFF reader identifies various CCITT encodings, but PIL doesn't
include codecs for this format.  This means that you can open the file,
but you cannot read the pixels from it.

I suggest using the "tiffcp" utility shipped with libtiff (www.libtiff.org)
to "decompress" the file before reading it with PIL:

    def tiffopen(filename):
        os.system("tiffcp -c none %s temp.tif" % filename)
        im = Image.open("temp.tif")
        os.remove("temp.tif") # on windows, you have to load the data first
        return im

    im = tiffopen("myfile.tif")

    for frame in ImageSequence.Iterator(im):
        ...

</F>