Question

I'm using Pillow 2.2.1 (installed it with pip) on Ubuntu Server 12.04 64-bit and trying to batch resize images into jpeg format. I've also installed both zlib1g-dev and libtiff-dev with apt-get.

I use the following line

   Image.open(path/to/image)

to open the image files (jpeg and tiff's). I can open some tiff images, but for others I just get the following error:

   File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 2006, in open
     raise IOError("cannot identify image file")

Since this doesn't occur for every tiff image I try to open does this mean that these files are corrupted? I have no problem opening the images in question with windows photo viewer or even with GIMP though.

Note: All the images were just given to me by my client so I have no idea how he digitized the images (scanned or took a picture of them is my best guess), or if that even matters.

Am I missing a package or dependency, or is there really just something about the image files that I'm not seeing?

Was it helpful?

Solution

TIFF is only a container format (like AVI on the video). The file extension does not actually signify how the image data inside is encoded. Most professional photo editing applications create their own flavour of TIFF which is unreadable in other software. PIL might support only certain subset of TIFF flavours (e.g. uncompressed).

If your system is a web upload style system I suggest you stop accepting TIFF format to avoid problems altogether.

More information: http://en.wikipedia.org/wiki/Tagged_Image_File_Format

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top