PIL cannot open TIFF image in Windows

  • Thread starter Andres Corrada-Emmanuel
  • Start date
A

Andres Corrada-Emmanuel

Hello,

I have installed PIL 1.1.5 on Windows with Python 2.4. I'm unable to open .tiff
images that I can open and view using Windows Explorer. In other words, this
simple test fails:

import Image
im = Image.open('small.tif')

with an 'cannot identify image file' error message. I'm able to open .jpg
images. Is PIL's support for TIFF images dependent on something else in Windows?

--------------------------------------
Andres Corrada-Emmanuel
Lecturer in Physics/Physics Department
Research Fellow/Computer Science Department
University of Massachusetts at Amherst
--------------------------------------
 
R

Rob Williscroft

Andres Corrada-Emmanuel wrote in
in
comp.lang.python:
I have installed PIL 1.1.5 on Windows with Python 2.4. I'm unable to
open .tiff images that I can open and view using Windows Explorer. In
other words, this simple test fails:

import Image
im = Image.open('small.tif')

with an 'cannot identify image file' error message. I'm able to open
.jpg images. Is PIL's support for TIFF images dependent on something
else in Windows?

I downloaded some test images from:

<url:http://www.remotesensing.org/libtiff/images.html>

I then ran a test:

LIBTIFFPIC = r".\libtiffpic"

import Image, os

def main():
ok = error = 0
for root, sub, files in os.walk( LIBTIFFPIC ):
for i in files:
if i.endswith( '.tif' ):
full = os.path.join( root, i )
try:
tiff = Image.open( full )
except:
print "error:", full[ len( LIBTIFFPIC ) + 1 : ]
error += 1
else:
print "ok: ", full[ len( LIBTIFFPIC ) + 1 : ]
ok +=1

print "ok:", ok, "\terror:", error, "\ttotal:", ok + error

main()

The final line gave:

ok: 28 error: 33 total: 61

So I only managed to load 28 of the 61 test images, AFAIK I
have never installed anything special to get PIL to work
with tiff images.

As a side note The GIMP <url:http://www.gimp.org/> wouldn't load
some of the images too (I didn't test all), it had problems with
64 bit floating point images and images with RBGA data in them.

Rob.
 
I

Iain King

Michele said:
I do the same and modified your code for try FreeImagePy and the results
are:

ok: 41 error: 20 total: 61

Better than PIL, but a lot of problems with

lower-rgb-planar- > 8 and flower-rgb-contig- > 8

IrfanView seem that can load all the images...


Bye,
Michele

I've been working with tifs a lot, and I've yet to find a perfect
python solution to them. The usual images to screw things up for me
are jpeg encoded pages. Best solution I've found is a try/except fall
through:
try:
open image with PIL
except:
try:
open image with FreeImagePy
except:
try:
open image with wxPython
except:
fail

Right now my program to compile multipage tiffs no longer does any of
the image work itself - it processes the index file, and then generates
a batch file. The batch file is a lot of calls to irfanview /append.
I've yet to find a tiff irfanview can't open.

Iain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top