[Zope] Resizing an Image with PIL via a Form Upload

Tom Von Lahndorff tom at modscape.com
Thu Feb 22 13:29:10 EST 2007


I'm trying to resize an image uploaded from a form using PIL. I got it 
to work on an existing image but I can't seem to get it to work on an 
image that's uploaded through the form. The ID of the file I'm trying to 
upload is "DSCF0004.jpg". The form, script and traceback are listed 
below. Thanks in advance.

<form action="processed/imgSizer" method="post" 
enctype="multipart.form-data">
<input type="file" name="original_id"> <input type="submit" 
name="submit" value=" Add ">
</form>

(imgSizer External Method)
1 def makeImages(self, original_id):
2 
3    import PIL.Image
4    import PIL
5    from StringIO import StringIO
6    import os.path
7
8    original_image=getattr(self, original_id)
9    original_file=StringIO(str(original_image.data))
...

returns:

Traceback (innermost last):

    * Module ZPublisher.Publish, line 115, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 41, in call_object
    * Module Products.ExternalMethod.ExternalMethod, line 225, in __call__
      __traceback_info__: ((<Folder at /dev/imgtest/processed>,
      'DSCF0004.jpg'), {}, None)
    * Module .../Zope/Extensions/imgSizer.py, line 9, in makeImages

AttributeError: DSCF0004.jpg



More information about the Zope mailing list