[Zope] Photo Product fix/question/suggestion

Gregor vorlon@iglou.com
Mon, 10 Jan 2000 20:34:31 -0500


Question:
I have a class "FoobarInfo" that has an "image" property.  This property holds
the ID of an image to be rendered in FoobarInfo's index_html method.

Therefore, in the index_html I was doing this:

<img class="fooimage" alt="[Image for <dtml-var name>]" src=<dtml-var image> >

And this works just spiffy.  However, I want to use the Photo Product instead
of the Image class.  The code above works for Photo, too, but it does not take
advantage of Photo's features.  Now, normally you would insert the following
into a document to render the image and use the feature I want (specifically,
a user's preferred display size):

<dtml-var "blah(REQUEST, pdcookie='1')">

Where "blah" is the ID of the Photo instance you want to insert.

My problem is that I'm not sure how to say "blah should be the object referred
to by my image property", and I'm also not sure how to set the class and alt
text in this usage (putting them after pdcookie didn't work).  I've tried all
sorts of weird stuff with _, getitem, dtml-with, dtml-let, but to no avail.

Alternately, figuring out how to use this "pdcookie" feature from a normal
<img> tag would work too.

(I also tried deriving my class from Image or Photo and adding my extra Info
properties, but that was even harder to figure out.  At least this way it
sort-of works.)



Fixing the default Image Formats:
The __init__.py file that the Photo Product supplies for PIL only supports the
GIF image type by default, which is weird behavior these days.  I thought it
was a bug at first. ;-)

To enable other formats, open the __init__.py that you put in PIL's directory,
and add the desired Image plugins onto the import list.  Mine looks like so,
now:

import Image, ImageFile, ImageDraw,  _imaging, GifImagePlugin,
JpegImagePlugin, PngImagePlugin

This seems to work fine.  All of the plugins are in PIL's directory, so look
there to figure out whether one is available for a given format.

(I plan to remove GifImagePlugin, because frankly I never use GIF if I can
avoid it).


Suggestion:
As far as the Photo Product itself is concerned, I think that the default size
for thumbnails is way too huge.  128x128 seems more alike a preview size than
a thumbnail (I would put the latter at more like 32x32 or 64x64).  I know I
can fix it (says so right in the docs), but I thought I might put in my 2
cents on that ;-)

- Gregor  vorlon#iglou.com
http://anime.at/gregordyne
http://www.skysys.org/~gregor
Anime, Amber, 3d, Mage, Eidolon, Miscellany