easy-thumbnails
easy-thumbnails copied to clipboard
Generating thumbnail from URL
Currently there is no way to generate a thumbnail from the file fetched through URL (external source).
Looking forward to this feature as well. Currently working on a work around.
easy-thumbnails can create a thumbnail from any file-like object.
The thumbnail won't be cached against this external source, but you can still generate the thumbnailed image.
import StringIO
import urllib2
import urlparse
from easy_thumbnails.files import get_thumbnailer
url = 'http://python.org/images/python-logo.gif'
p = urlparse.urlparse(url)
source = StringIO(urllib2.urlopen(url).read)
thumbnailer = get_thumbnailer(source, related_name=p.netloc + path)
opts = {'size': (30, 30)}
# This will just give you a file you can save somewhere
thumb = thumbnailer.build_thumbnail(opts)
# Or alternately, this will save the thumbnail to your media_root as:
# 'python.org/images/python-logo.gif.30x30_q85.png'
thumb = thumbnailer.get_thumbnail(opts)