[Zope] Using PIL in zope product

Garito garito at sistes.net
Wed Dec 29 10:23:47 EST 2004


A!
I have no idea about that!
I'm using the product with PIL generation with out problems for now
Thanks for the info!

Jonathan Cyr wrote:

> FYI,
>
> Photo and Photo Folder seem to have a problem with PIL-generated image 
> data... ie. creating a photo object with data processed by PIL.
>
> My answer was to use VarImage instead, seems to be more closely 
> related to Zope's Image object, and can receive Zope data as you think 
> it would.
>
> Also, There's a simple script tutorial on using PIL in the Zope Book, 
> I think it's under external python scripting.
>
> -Jon
>
>
>
> Garito wrote:
>
>> Did you know Photo and Photo folder product?
>>
>>
>> John Schinnerer wrote:
>>
>>> Hello,
>>>
>>> I am developing an art-gallery type of product, with images of artworks
>>> stored as zope Image objects within a folderish product instance.
>>>
>>> When a new gallery item instance is created, or when the Image object
>>> in an existing instance is changed, I want to auto-generate a thumbnail
>>> of the image (using PIL) and store it also as a zope Image object.
>>>
>>> In manage_addAction for example I have this:
>>> ...
>>> imgfile = REQUEST.image_file
>>>     if imgfile and imgfile.filename != '':
>>>         newObjId.manage_addImage('art_piece', imgfile, newObjId.title)
>>>         newObjId.manage_addImage('art_piece_thumb', makeThumb(imgfile),
>>> newObjId.title) ...
>>>
>>> and here is makeThumb (using PIL):
>>>
>>> def makeThumb(imagefile):
>>>     "create thumbnail image from full-size art_piece image"
>>>     img = Image.open(imagefile)
>>>     thumb = img.thumbnail((111,111), Image.ANTIALIAS)
>>>     return thumb
>>>
>>> I get a zope error triggered by the line
>>>
>>> img = Image.open(imagefile)
>>>
>>> like this:
>>>
>>> Error Type: AttributeError
>>> Error Value: FileUpload instance has no attribute '__getitem__'
>>> (traceback further below if helpful)
>>>
>>> So apparently there is some problem with trying to use the image file
>>> passed in the request with the PIL functions...it's not a "real" file
>>> or at least doesn't have some attributes that PIL is expecting to find,
>>> or something like that.
>>>
>>> Is there a simple way around this the way I'm trying to do it?
>>>
>>> If not, how else could I try to get the same result (a zope Image
>>> object thumbnail image created from the 'full size' image being
>>> uploaded in the request)?
>>>
>>> thanks,
>>> John S.
>>> ---------------
>>>
>>> Traceback (innermost last):
>>>  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 150, in
>>> publish_module
>>>  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 114, in
>>> publish
>>>  File /usr/lib/zope/lib/python/Zope/__init__.py, line 159, in
>>> zpublisher_exception_hook
>>>    (Object: bg)
>>>  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 98, in
>>> publish
>>>  File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 88, in
>>> mapply
>>>    (Object: add_GTIGalleryItem)
>>>  File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 39, in
>>> call_object
>>>    (Object: add_GTIGalleryItem)
>>>  File /usr/lib/zope/lib/python/Shared/DC/Scripts/Bindings.py, line
>>> 252, in __call__
>>>    (Object: add_GTIGalleryItem)
>>>  File /usr/lib/zope/lib/python/Shared/DC/Scripts/Bindings.py, line
>>> 283, in _bindAndExec
>>>    (Object: add_GTIGalleryItem)
>>>  File /usr/lib/zope/lib/python/Products/PythonScripts/PythonScript.py,
>>> line 302, in _exec
>>>    (Object: add_GTIGalleryItem)
>>>    (Info: ({'script': <PythonScript instance at 892f4c0>,
>>> 'context': <Folder instance at 8988608>, 'container': <Folder
>>> instance at 8b8d860>, 'traverse_subpath': []}, (), {}, None))
>>>  File Script (Python), line 11, in add_GTIGalleryItem
>>>  File
>>> /usr/lib/zope/lib/python/Products/GTIGalleryItem/GTIGalleryItem.py,
>>> line 98, in manage_addAction
>>>  File
>>> /usr/lib/zope/lib/python/Products/GTIGalleryItem/GTIGalleryItem.py,
>>> line 71, in makeThumb
>>>  File /usr/lib/python2.1/site-packages/PIL/Image.py, line 984, in open
>>>  File /usr/lib/zope/lib/python/App/ImageFile.py, line 35, in __init__
>>>  File /usr/lib/python2.1/posixpath.py, line 48, in join
>>> AttributeError: (see above)
>>>
>>>
>>>
>>>
>>>        __________________________________ Do you Yahoo!? Dress up 
>>> your holiday email, Hollywood style. Learn more. 
>>> http://celebrity.mail.yahoo.com
>>> _______________________________________________
>>> Zope maillist  -  Zope at 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 maillist  -  Zope at 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 maillist  -  Zope at 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 )




More information about the Zope mailing list