473,657 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PIL problem: IOError: cannot identify image file

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.pn g'))

results in

File "C:\Program Files\Python24\ lib\site-packages\PIL\Im age.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?

Aug 20 '06 #1
2 22891
Doh! Apparently Image.open() wants a path, not a file. So

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

works fine.

Aug 20 '06 #2
h1*****@gmail.c om wrote:
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>

Aug 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
8662
by: Roger Withnell | last post by:
I would like to check that an image file, selected by a user using fileUpload, is within certain parameters (width, height, filesize) and to display the image file so that the user can see the correct image has been chosen, before uploading it to the server. http://www.your-community.co.uk/TestImageArray.asp is an extract of the basic functions which work in IE but not in NN (the alerts are just tests to see what is going on). It...
3
2812
by: Scott | last post by:
Hello, I am running into a problem with my code and can't seem to figure out the solution. I know it has to do with the pciture box control and unloading the image inthe picture box but I can't seem to figure out the correct way to "unload" the file. I have a simple form with a picture box and a button. I am using dir() to get all the the .tif files and display them in the pciture box. Each time the button it pressed it displays the...
3
2821
by: thebhone | last post by:
I am creating a website updater program. Currently working on the image replacement module here. For some reason, after an image (say /images/1.jpg) has been used/opened in the application. I cannot later overwrite it (during the application), even after i have closed it.
1
3076
by: Daniel Mark | last post by:
Hello all: I have following code that works well under command line, but it doesn't work after I convert it as exe application. ############### file: testPath.py import getopt, math, sys, os, Image, ImageDraw, aggdraw def processline():
12
6380
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
Other than installing PIL, is there a "simple" way using Python only to determine if a file is a valid image file? I'd be happy if I could at least identify valid images files for gif, jpeg and png. Pointers to existing modules or examples would be appreciated. The reason why I'd prefer not using PIL is that I'd like to bundle such a function/module in my app.
0
1395
by: fatality123 | last post by:
hi all I am new to both python and image processing. My task is to use python and tk to create a tool which can convert between the difft RGb color spaces like 565,888,444 etc and difft YCbCr color spaces like 444,422,420and 411. I read abt PIL and installed it.I am working in Windows XP environment. to do this task i am facing the following problems: 1.read and write image files in difft formats like ppm,pgm,bmp in both binary and ascii...
1
2144
by: Sinan Alkan | last post by:
Hi All, I have a method to resize any image file to the specific dimensions and save this new image to a path. I found it on a web page(By Joel Neubeck) and i changed it for my project. The code is as follows; --------------------------------- // usings part using System.Drawing; using System.Drawing.Imaging;
0
1845
by: newsco | last post by:
Dear all, I use VB6 ADO connect to Access 2007 accdb database, everything is fine except I cannot retrieve image file stored in the Access 2007 attachment data type. Can anyone show me some vb code on how to do that? Thanks. Patrick
6
4626
by: vertigo262 | last post by:
I don't know why this does this on the delete. any ideas? line 289 --------------------------------------------- The process cannot access the file 'D:\InetPub\ReefJunkies\Users\bill\Profile\PictureThumb\340x_la-rouxsmall.jpg' because it is being used by another process.
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.