Hi people!

I've done a method to resize images on demand on a template, it is a
simple filter that made use of PIL.Image, see the following template
code:

...
<img src="{{ object.get_image_url }}" alt="original image">
<img src="{{ object.image|miniaturalize }}" alt="default 200x200">
<img src="{{ object.image|miniaturalize:"300x300" alt="resize to
300x300">
...

The code is already running, but I have another approach, reather than
use a filter, I can define an automatic custom method on the model
instance:

...
<img src="{{ object.get_image_url }}" alt="original image">
<img src="{{ object.get_image_200x200 }}" alt="default 200x200">
<img src="{{ object.get_image_300x300 }}" alt="resize to 300x300">
...

This is not done, I've start with this point but I found easier to
implement a filter. In both cases, when I call the filter or when I
call the custom method of the model, it checks if the image was
resized. This is done by looking at a file called image_200x200.jpg
(supposing the size is 200x200 and the original filename is
image.jpg). This term resize isn't appropriated, I make a thumbnail of
the image at the maximum size of 200x200.

Well, what do you think about my idea? Is it usefull? And the most
important :), where can I store it? Should I put it on
defaultfilters.py (if you think it is usefull)? Should I create a
snippet? Should if goes into a contrib package?

Best regards!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to