[Zope] Zooming images
Jeff Rush
Jeff Rush" <jrush@timecastle.net
Mon, 18 Oct 99 15:41:42 -0500
Hi Rafael,
There are two approaches to your image sizing problem, neither
of which are Zope-specific.
The first is to use the HTML IMG tag with varying sizes and let
the browser resize the image:
<IMG SRC="photo1.png" HEIGHT=100 WIDTH=100>
-or-
<dtml-var "_.vars['photo1.png'].tag(HEIGHT=100, WIDTH=100)">
and then for the same image at a different size:
<IMG SRC="photo1.png" HEIGHT=200 WIDTH=200>
-or-
<dtml-var "_.vars['photo1.png'].tag(HEIGHT=200, WIDTH=200)">
And the second approach is to use the Python Image Library to
read in and rescale your images, either on the fly (real slow!) or
to store two representations as attributes of a object's instance.
In approach, perhaps you ought to create a new ZClass called
'Photograph' and provide auto-generation of several image
sizes when the image is updated, and a couple of methods
that return the image in different sizes.
<dtml-var "photo1.thumbnail()">
-and-
<dtml-var photo1> for the full-size rendition
I am finishing up my "Equation Tiles" python (not zclass) product
which uses these techniques. I'll be posting it when done, so
you are welcome to use it as a starting point for "Photograph".
-Jeff Rush
On Sun, 17 Oct 1999 19:21:17 +0200, Rafael Cordones Marcos wrote:
>The thing is this cases also contain photos. I would like users
>to be able to enlarge them. What is the 'Zope' way to do this? I mean,
>do I have to have two Image objects, small and large? Maybe I could
>make a function that given an Image object and a height and with
>parameters would return an Image object with the small image. Anybody
>knows of some code/docs where I could start?