Zope+PIL+ image resizing
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
You must include the full traceback. And please don't post in HTML. Florent In article <016201c4db77$2d2f9220$0c00a8c0@programista1> you write:
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
-- Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D +33 1 40 33 71 59 http://nuxeo.com fg@nuxeo.com
participants (2)
-
Florent Guillaume -
Krzysztof Kubacki