#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    30
    Rep Power
    0

    Image class not finding image on a website


    I'm trying a simple image initialization... but alas alack and stuff...


    Code:
    '''imports'''
    
    ##! /usr/local/bin/python
    import sys, Image, urllib
    
    image = 'http://www.footymania.com/images/banners/bannerdan.png'
    
    im = Image.open(image)
    I get the following error message

    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.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    30
    Rep Power
    0
    AAaaaaaaaah... makes sense.. bummer though, cause I know you can do that with the php image library.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo