Skip to content

Instantly share code, notes, and snippets.

@wenbert
Created December 29, 2010 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wenbert/758243 to your computer and use it in GitHub Desktop.
Save wenbert/758243 to your computer and use it in GitHub Desktop.
get url of image and save to local file
#example2.py
import cStringIO # *much* faster than StringIO
import urllib
import Image
file =
urllib.urlopen('http://freegee.sourceforge.net/FG_EN/src/teasers_en/t_gee-power_en.gif')
im = cStringIO.StringIO(file.read()) # constructs a StringIO holding the image
img = Image.open(im)
# now use PIL
print img.format, img.size, img.mode
img.save('my_copy.gif')
# delete img if you need to save space and work on large images
del img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment