PIL + Zope + resizing images

K

KK

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top