Skip to content

Instantly share code, notes, and snippets.

@wenbert
Created December 29, 2010 06:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wenbert/758257 to your computer and use it in GitHub Desktop.
Save wenbert/758257 to your computer and use it in GitHub Desktop.
Python save image from URL
import cStringIO # *much* faster than StringIO
import urllib
import Image
try:
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)
img.save('/home/wenbert/uploaderx_files/test.gif')
except IOError, e:
raise e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment