[Zope-CMF] Re: StringIO error
Rainer Thaden
Rainer Thaden <thadi@gmx.de>
Thu, 26 Jun 2003 15:57:44 +0200
RT> i have a little script makeThumbnails which automatically generates
RT> thumbnails of images on certain pages. In most cases it works. But in
RT> some cases i get the following error:
RT> 8<------- snipped first part --------->8
RT> Module Script (Python), line 8, in makeThumbnails
RT> - <PythonScript at /CMFTest/ITA/makeThumbnails used for /CMFTest/ITA/ITA/Mitarbeiter/jkl>
RT> - Line 8
RT> Module Products.ITA.ita_utils, line 66, in makeThumbnail
RT> TypeError: expected string, ImplicitAcquirerWrapper found
RT> The code is here:
RT> from PIL import Image
RT> from cStringIO import StringIO
RT> import os.path
RT> # create a thumbnail image file
RT> original_image=getattr(self, original_id)
RT> # the line below must be responsible for the error i think:
RT> original_file=StringIO(original_image.data)
RT> image=Image.open(original_file)
RT> image=image.convert('RGB')
RT> image.thumbnail((size,size))
RT> thumbnail_file=StringIO()
RT> image.save(thumbnail_file, "JPEG")
RT> thumbnail_file.seek(0)
RT> The image is a jpg, which is uploaded in a Portal Image.
RT> Any ideas?
Anyone who's interested:
Think i found it:
http://www.zopelabs.com/cookbook/1010702887
--
Regards,
Rainer mailto:thadi@gmx.de