[Zope] Re: PIL: can't call same method twice
KLEIN Stéphane
stephane at harobed.org
Mon May 30 18:13:01 EDT 2005
Chris Withers a écrit :
> Chris wrote:
>
>> Hi David,
>>
>> this is not the problem (tried it before).
>>
>> The code
>> foo = container.resize(context.REQUEST.image, size=size) # works nicely
>
>
> at this point, try inserting:
>
> context.REQUEST.image.seek(0)
>
>> foo = container.resize(context.REQUEST.image, size=size) # 2nd time
>> ->error
>> does what you suggest. But it raises the same error.
>
>
> cheers,
>
> Chris
>
I've the same problem and now it's work with this tip :
"context.REQUEST.image.seek(0)".
My xImageScale.py [external method] is :
def xImageScale(img_file, maxx, maxy):
from PIL import Image
from cStringIO import StringIO
img_file.seek(0)
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
-- Stéphane
More information about the Zope
mailing list