[Image-SIG] Re: How to open image file via HTTP and save locally?
Fredrik Lundh
fredrik at pythonware.com
Wed Apr 21 07:08:16 EDT 2004
Anastasios Hatzis wrote:
> I want my Python script to read a remote image file on a web server
> (e.g. JPG) and then save it locally.
>
> I imported PIL 1.1.4 on my Python 2.3.2 (Windows XP) and everything
> works fine while I read locally stored image files, using the PIL.
>
> But I can't find an example or description, how to open an image file,
> if it is not local but on a remote Web server ...
> - neither in PIL handbook, Python website, nor in various mailing
> archives.
if you want PIL to open the file from the web:
import urllib
import Image
im = Image.open(urllib.urlopen(URL))
if you just want to download the file to a local directory:
import urllib
urllib.urlretrieve(URL, FILENAME)
see also:
http://www.python.org/doc/current/lib/module-urllib.html
http://effbot.org/zone/pil-image-size.htm
</F>
More information about the Image-SIG
mailing list