Re: [Zope] Re: PIL: can't call same method twice

2005-05-31 Thread Dieter Maurer
KLEIN Stéphane wrote at 2005-5-31 00:13 +0200:
 ...
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

You need to learn that you *MUST* provide a *FULL* problem description
when you seek help. This includes Error Type, Error Value
and Traceback in case you get an exception, and otherwise a clear
description what went wrong.

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: PIL: can't call same method twice

2005-05-30 Thread KLEIN Stéphane

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

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )