PIL cannot open TIFF image in Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andres Corrada-Emmanuel

    #1

    PIL cannot open TIFF image in Windows

    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('sma ll.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
    --------------------------------------
  • Rob Williscroft

    #2
    Re: PIL cannot open TIFF image in Windows

    Andres Corrada-Emmanuel wrote in
    news:mailman.20 8.1157809477.52 79.python-list@python.org in
    comp.lang.pytho n:
    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('sma ll.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.remotesensi ng.org/libtiff/images.html>

    I then ran a test:

    LIBTIFFPIC = r".\libtiffp ic"

    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.
    --

    Comment

    • Michele Petrazzo

      #3
      Re: PIL cannot open TIFF image in Windows

      Rob Williscroft wrote:
      I downloaded some test images from:
      >
      <url:http://www.remotesensi ng.org/libtiff/images.html>
      >
      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...
      Rob.
      Bye,
      Michele

      Comment

      • Iain King

        #4
        Re: PIL cannot open TIFF image in Windows


        Michele Petrazzo wrote:
        Rob Williscroft wrote:
        >
        I downloaded some test images from:

        <url:http://www.remotesensi ng.org/libtiff/images.html>
        >
        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...
        >
        Rob.
        >
        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

        Comment

        Working...