[Zope-dev] Zope+PIL+ image resizing
Krzysztof Kubacki
krzysztof.kubacki at bmpg.pl
Mon Dec 6 04:37:13 EST 2004
Hallo.
I have Zope 2-7-0 on Linux platform and the following problem :)
I'm sending an image through form on the pythonScript. I want script to
resize image and save on the zope folder in 3 different size. OK, I use
ExternalMethod which uses PIL library to resize these images.
External method:
def xImageScale(img_file, maxx, maxy):
from PIL import Image
from cStringIO import StringIO
im = Image.open(img_file)
im.thumbnail((maxx, maxy), Image.ANTIALIAS)
out_file_str = StringIO()
im.save(out_file_str, im.format)
out_file_str.seek(0)
tmp=out_file_str.read()
out_file_str.close()
return tmp
pyrthonScript:
cAnimation = form.get('cAnimation','') # image from the form
if cAnimation:
o.invokeFactory(id='cAnimationS.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 100, 100)
o.invokeFactory(id='cAnimationM.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 200, 200)
o.invokeFactory(id='cAnimationB.'+timeStamp, type_name='Image',
file=context.xImageScale(cAnimation, 300,300)
The result is "IOError, cannot identify image file". So, when I want to
resize and save only one image it works properly.
Thanks in advance for any help
KK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-dev/attachments/20041206/3c389458/attachment.htm
More information about the Zope-Dev
mailing list