April 28th, 2004, 10:28 PM
Image class not finding image on a website
I'm trying a simple image initialization... but alas alack and stuff...
I get the following error message
import sys, Image, urllib
image = 'http://www.footymania.com/images/banners/bannerdan.png'
im = Image.open(image)
File (location of file\Image.py), Line 1543, in open
fp = __builtin__.open(fp, "rb")
IOError: [Errno 2] No such file or directory: 'http://www.footymania.com/images/banners/bannerdan.png'
This happens for all types of images online even though i know they exist. I tested it out with the google logos as well, and the same error takes place.
April 29th, 2004, 02:45 AM
The problem your getting is that your trying to pass a URL to Image.open when it wants a local path.
If you really want to load an image from online then you will probably need to use urllib.urlopen() to get the image as a string (or write it to a file) and then load the image into PIL from the string (or file).
Hope this helps clear things up,
April 29th, 2004, 09:27 AM
AAaaaaaaaah... makes sense.. bummer though, cause I know you can do that with the php image library.
April 30th, 2004, 04:12 AM
Ah but then PHP was designed spacifically for the web so it makes sence that you can use URL's as paths in some functions where Pythons design is alot more general perpose yet infinatly nicer IMO.