PIL problem: IOError: cannot identify image file

H

h112211

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?
 
H

h112211

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

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

works fine.
 
F

Fredrik Lundh

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>
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top