[Zope] Re: Generating thumbnails on the fly using PIL
Pieter Claerhout
Pieter_Claerhout@CreoScitex.com
Tue, 27 Nov 2001 21:45:49 +0100
Hi all,
I got quite a lot further now. Here's the script I have so far:
import PIL.Image
import os.path
import cStringIO
def MakeThumb(self, image, width, height):
oriImage = getattr(self, image)
oriFile = cStringIO.StringIO(oriImage.data)
image = PIL.Image.open(oriFile)
image.thumbnail((width, height))
thumbnailImage = StringIO()
image.save(thumbnailImage, "JPEG")
thumbnailImage.seek(0)
return thumbnailImage.getvalue()
this all works find if you use it as:
<dtml-var "PHTO_MakeThumb('AB_action_inbox.jpg', 160, 120)">
As soon as you want to do something like:
<dtml-var "PHTO_MakeThumb('/images/AB_action_inbox.jpg', 160, 120)">
you get an AttributeError. Does anybody has a way around this?
Cheers,
Pieter