[Zope-CMF] StringIO error

Rainer Thaden Rainer Thaden <thadi@gmx.de>
Thu, 26 Jun 2003 14:46:29 +0200


Hi,

i have a little script makeThumbnails which automatically generates
thumbnails of images on certain pages. In most cases it works. But in
some cases i get the following error:

8<------- snipped first part --------->8

  Module Script (Python), line 8, in makeThumbnails
   - <PythonScript at /CMFTest/ITA/makeThumbnails used for /CMFTest/ITA/ITA/Mitarbeiter/jkl>
   - Line 8
  Module Products.ITA.ita_utils, line 66, in makeThumbnail
TypeError: expected string, ImplicitAcquirerWrapper found

The code is here:

    from PIL import Image
    from cStringIO import StringIO
    import os.path

    # create a thumbnail image file
    original_image=getattr(self, original_id)

    # the line below must be responsible for the error i think:
    
    original_file=StringIO(original_image.data)
    image=Image.open(original_file)
    image=image.convert('RGB')
    image.thumbnail((size,size))
    thumbnail_file=StringIO()
    image.save(thumbnail_file, "JPEG")
    thumbnail_file.seek(0)

The image is a jpg, which is uploaded in a Portal Image.

Any ideas?

-- 
Regards,
 Rainer                          mailto:thadi@gmx.de