Open siovene opened 10 years ago
This is a somewhat frequent feature request. Personally, it's not a feature I'm interested in but if someone wants to do the work, I'll let it in.
Make a url_thumbnailer
filter
It can be passed a url string or a urllib2 file-like object (so people can do ther own business logic like getting a url with a custom user agent).
Returns a Thumbnailer
instance initialized with remote_source=True
.
Set the thumbnailer's relative_name to something reasonably unique (let's say url/{sha1hash-of-full-url-salted-with-first-10-chars-of-secret_key}.{extension}
)
This is a feature I'm also interested. I would like to generate thumbnails from URL's, and directly from python code.
Could you please explain what you mean by "Make a url_thumbnailer filter"?
Thanks in advance
There's a thumbnailer
template filter a the moment that returns a Thumbnailer
instance. This new filter would do the work of converting a url string to a urllib2 file-like object and the initializing the instance as I said.
If all you want to do is do this directly from python, you can already - just pass the file-like object (probably generated with urllib2.urlopen
) to get_thumbnailer
with some relative_name
So, from python code I tried to do this:
img = urllib2.urlopen('http://www.anuncommonfamily.com/wp-content/uploads/2011/08/soccer-ball.jpg')
thumbnailer = get_thumbnailer(img, relative_name='apps/logos/soccer-ball.jpg')
thumb = thumbnailer.get_thumbnail({'size': (100, 100)})
But I get the following exception:
Exception Type: AttributeError
Exception Value:
addinfourl instance has no attribute 'closed'
Which occurs in generate_source_image
from engine.py
. Isn't this the way you said it is supposed to work?
Thanks again
@dpflucas you'll see I just committed something to make this work better. For now, you could probably just do img = StringIO(img.read())
Thanks, it is now working with the StringIO trick!
Hi, this is a feature request.
I'd like to generate thumbnails starting from a URL, the way sorl-thumbnails does.
Can this be added to easy-thumbnails?
Additionally, I'd like a setting to specify which user-agent to use when fetching the image (presumably with urllib2).
Thanks in advance!