You are not logged in Log in Join
You are here: Home » Members » Marc's Zope Page » ImageTag_CorePatch » 0.3 » README.txt » View Document

Log in
Name

Password

 

README.txt

HotPatch Image.tag to use PIL to size images (useful for thumbnails).
Also fixes so-called intelligent scaling to actually be intelligent.

Here's an example of using the new thumb method directly:

<img src=""
tal:on-error="structure string:<img src='${img/absolute_url}' alt='${here/title}' align=${alignment} hspace=${hs} vspace=${vs} border=${brd}) />"
tal:attributes="src string:${img/absolute_url}/thumb?width=100&imtype=PNG;
align alignment;
hspace hs;
vspace vs;
border brd"/>

What that does is try to use thumb, and if it doesn't work fall back to rendering the image normally. It also shows usage of some of the extended properties. Since only width is specified the image will be proportionally resized (same applies for height only), and the imtype converts it to PING (check PIL docs, but the most useful types are JPEG, GIF, PNG), which preserves any transparency (alpha) the image might have.


Here's an example of using tag with PIL resizing:

<span tal:replace="structure python:img.tag(width=200) />

or

<span tal:replace="structure python:img.pil_tag(width=200) />

Note that this patch adds 'pil_tag' which you can test for if you're not sure tag() has been re-patched (evidently Plone does this)


TO DEAL WITH PIL:
first install PIL according to directions
then go to your zope's /lib/python folder (with products,ofs, all that in it, ya know?)
type this command:
ln -s /usr/lib/python1.5/site-packages/PIL
this creates a symbolic link to your installed PIL so Zope can find it.

NOTE that with zope 2.5.x and newer (with newer Pythons), you can usually just install PIL in your local Zope's site-packages directory and it will be importable. Check your startup log to see if the import succeeds.