PIL cannot open TIFF image in Windows

Rob Williscroft rtw at freenet.co.uk
Sat Sep 9 10:40:45 EDT 2006


Andres Corrada-Emmanuel wrote in
news:mailman.208.1157809477.5279.python-list at python.org 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.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list