[Zope] Re: image hot fix

Ausum augusto@artlover.com
Mon, 27 Aug 2001 09:28:25 -0500


Marc I've tested your hotfix and it does work great at allowing the use of
PIL with the standard image tag method.
However, because  without the use of caching the rendering of a simple
thumbnail page may become a real pain, (the thumbnails will always
regenerate from the original images, over a over again every time the page
is loaded), it would be really helpful that you provide a how-to/readme on
the subject of the use of RAMCache along with your product.

On the other hand I'd like to point out that PIL - although it's a familiar
Python native library to work with-  has serious lacks of image quality
after resampling. The jaggy look of thumbnails is unpleasant for a
professional site. Why is that?  I've tested the three available methods
(nearest, bilinear and bicubic), with a large-size image (2000 X 1500 or so)
finding that at a thumbnail level all the samples looked the same. And
bicubic is the best known (and costly) resample method. A search at the
Image-sig archives also reveals the problem, apparently leading  to the use
of GIMP with a Python interface -instead of PIL-, when quality becomes a
concern.

Has anyone found a workaround for the jaggy look of PIL's resized images in
Zope?



Ausum



----- Original Message -----
From: "marc lindahl" <marc@bowery.com>
To: "Philip Aylesworth" <phila@purpleduck.com>


> Hi Philip,
> I'm cc'ing the list, perhaps someone has some input...  comments
> interleaved.
>
> > From: Philip Aylesworth <phila@purpleduck.com>
> > Date: Thu, 23 Aug 2001 20:36:13 -0400 (EDT)
> > To: info@bowery.com
> > Subject: image hot fix
> >
> >
> > Hi Marc,
> >
> > I have to tell you that this image hot fix is exactly what I need! I was
using
> > Photo but it is no longer supported and this does things more the way I
want
> > to.
> >
> > I am modifying it so that it will have several default sizes that can be
> > cached.
>
> Actually, if you look at the code, i *think* I have stuff in there to
allow
> you to use it with a RAMCache.  The idea being, make a RAM cache for
caching
> all thumbnail images, not just private caching for each instance.  I'm
still
> unfamiliar with how that all works in Zope, but architecturally I think
> that's the best place to put a cache (external to the images themselves).
I
> still don't see how to get this caching to work for all instances, it
seems
> the caches need to add one instance at a time...
>
> But this way, they are stored where appropriate (cached), but not stored
> inside the image (which could lead to unneccessary data.fs bloat).
>
> > I am not to swift with python yet so I just went in and duplicated the
thumb
> > method and made some methods called "preview", "small", and
"medium"giving
> > them
> > default sizes of 160X120, 320X 240, and 640X480.
>
> The way I have it working, if you call tag() with the same size twice, at
> the least, the client browser should use the locally cached version (at
> least, it did for me), so I don't see that it's necessary to have
specially
> named methods.  For example, in my CMFPhoto and in the original ZPhoto,
the
> thumbnail pages always call tag with a size of 80, so they'll be cached
(at
> least per client) the second time around.
>
> >I have this working now but I
> > noticed one little bug in your code. The "keys =" line reverses the
height and
> > width. I fixed this by replacing it with:
> >
> > keys = {'width':int(width or height), 'height':int(height or width)}
>
> Doh!  Thanks for pointing it out!  I guess that gives me a reason for
> version 0.2 (along with changing the name to image HotPatch!) -- though
I'm
> hoping to figure out the RAMCache situation (help! somebody!) first...
>
> >
> > Now I have one question, if you don't mind. How do I make the tag method
> > return
> > a URL for the size of image that I want? I see that you have thumb hard
coded
> > in
> > there. If you have time to take a look at this I would really appreciate
it.
>
> I have thumb hard coded (in tag), because that's the method the browser
will
> then call (with arguments) to actually fetch the image.
>
> I guess, if you're rolling with the three special method approach (though
I
> don't think it's necessary), then in tag I guess you'd either create a new
> parameter for tag (size=[preview,small,medium]) or match one of the three
> names with a range of sizes, and put more if/elses in there to return the
> right one.
>
> >
> > Thanks for the great work!
> >
> > Phil.
> >
> > Philip Aylesworth
> > phila@purpleduck.com
>