Tags: available, file, files, followingfrom, identify, image, imagei, import, installed, ioerror, newest, pil, programming, python, theirsite

PIL problem: IOError: cannot identify image file

On Programmer » Python

1,114 words with 2 Comments; publish: Thu, 03 Jan 2008 11:39:00 GMT; (200202.15, « »)

Hi,

I installed the newest available PIL (1.1.5 for Python 2.4) from their

site, but cannot seem to open any files. The following

from PIL import Image

i = Image.open(file('c:\\image2.png'))

results in

File "C:\Program Files\Python24\lib\site-packages\PIL\Image.py", line

1745, in open

raise IOError("cannot identify image file")

IOError: cannot identify image file

for any graphics file I've tried. Anyone know what's wrong?

All Comments

Leave a comment...

  • 2 Comments
    • Doh! Apparently Image.open() wants a path, not a file. So

      i = Image.open('c:\\image2.png')

      works fine.

      #1; Thu, 03 Jan 2008 11:41:00 GMT
    • h112211.python.todaysummary.com.gmail.com wrote:

      Quote:
      === Original Words ===

      Doh! Apparently Image.open() wants a path, not a file. So

      >

      i = Image.open('c:\\image2.png')

      >

      works fine.

      it works fine on files too, if you open them in *binary* mode.

      </F>

      #2; Thu, 03 Jan 2008 11:42:00 GMT