[Zope] PIL: convert an image-object back to file object

Christoph Landwehr chris-zopemailing at gmx.de
Thu Nov 13 13:33:19 EST 2003


Hi,

I use an external method utilizing PIL (python image library) to do some stuff 
with an image.

As I want to do the changes on-the-fly, I pass the fileUpload instance from my 
HTML-form to a python script. The script calls a external method. The external 
method uses PIL to convert the fielUpload instance to a PIL.Image.Image 
instance, does some stuff and returns the PIL.Image.Image instance to the python 
script.

In the script I want to save the returned object as an Zope image object using 
manage_addImage(). But the manage_addImage method expects a file object, not a 
PIL.Image.Image.

Here’s the traceback
Traceback (innermost last):
•	Module ZPublisher.Publish, line 98, in publish
•	Module ZPublisher.mapply, line 88, in mapply
•	Module ZPublisher.Publish, line 39, in call_object
•	Module Shared.DC.Scripts.Bindings, line 252, in __call__
•	Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
•	Module Products.PythonScripts.PythonScript, line 314, in _exec
•	Module Script (Python), line 13, in check
<PythonScript at /test/autoimage/check>
Line 13
•	Module OFS.Image, line 589, in manage_addImage
•	Module OFS.Image, line 434, in manage_upload
•	Module OFS.Image, line 469, in _read_data
AttributeError: Image instance has no attribute 'read'

How do I convert the image object back to a file object so I can add it to Zope?

Regards
Christoph





More information about the Zope mailing list