Skip to content

Instantly share code, notes, and snippets.

@frog32
Created September 4, 2010 21:17
Show Gist options
  • Save frog32/565500 to your computer and use it in GitHub Desktop.
Save frog32/565500 to your computer and use it in GitHub Desktop.
self.name = os.path.split(self.remote_path)[1]
download_temp = files.temp.NamedTemporaryFile(delete=True)
download_temp.write(urllib2.urlopen(self.remote_path).read())
download_temp.flush()
self.image_original.save(self.name, files.File(download_temp))
im=Image.open(self.image_original.path)
im.thumbnail((settings.POSTER_THUMBSIZE['x'], settings.POSTER_THUMBSIZE['y']), Image.ANTIALIAS)
img_temp = files.temp.NamedTemporaryFile(delete=True)
im.save(img_temp,'jpeg')
img_temp.flush()
self.image_thumb.save(self.name, files.File(img_temp))
self.save()
@frog32
Copy link
Author

frog32 commented Sep 4, 2010

Fill a django imageField with a image taken from a url and save a thumbnail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment