image from URL

Lee Morgan unknown at lee-morgan.net
Thu Oct 11 14:04:15 CEST 2001


Oleg Broytmann <phd at phd.pp.ru> writes:

> On Thu, Oct 11, 2001 at 05:46:01AM -0500, Randy Heiland wrote:
> > >>> import urllib, Image
> > >>> fp = urllib.urlopen("http://www.python.org/pics/PyBanner027.gif")
> > >>> im = Image.open(fp)
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> >   File "/home/heiland/PythonMod/Imaging-1.1.2/PIL/Image.py", line 944,
> > in open
> >     fp.seek(0)
> > AttributeError: addinfourl instance has no attribute 'seek'
> 
> im = Image.open(fp.read())
>    fp is not a file name, it is already file (file-like object, to be
> precise).
> 


import StringIO

im = Image.open(StringIO.StringIO(fp.read()))


> Oleg.
> ---- 
>      Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.
> 

-- 
Lee Morgan



More information about the Python-list mailing list