----- Original Message ----- From: "Tom Von Lahndorff" <[EMAIL PROTECTED]>
To: <zope@zope.org>
Sent: Thursday, February 22, 2007 1:29 PM
Subject: [Zope] Resizing an Image with PIL via a Form Upload

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 ">

(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
8    original_image=getattr(self, original_id)
9    original_file=StringIO(str(original_image.data))

just a guess, but i don't think getattr is returning what you think it is returning.

The image has not been 'stored' anywhere yet, it is just a FileUpload instance. To get at the information in this instance:

# the var name used in your form is misleading, it is not just the image id
fileName = self.REQUEST['original_id'].filename
fileData = self.REQUEST['original_id'].read()


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to