[Grok-dev] Problem with uploading image files and processing them
in the same request
sebastian at urbantalk.se
Wed Jan 30 12:19:23 EST 2008
In case someone finds this question in the archive. Turns out it was a
file.close -> file.close()
29 jan 2008 kl. 15.12 skrev Sebastian Ware:
> I am trying to upload image files and then creating a thumbnail in
> the same request. I get a...
> IOError: image file is truncated (57 bytes not processed)
> Is this due to the fact that the file hasn't been written to disk
> yet, and what can I do to avoid it?
> This is the code that I have put in my grok.action('Save')...
> obj.local_file_path = '/the/full/path/to/my/file'
> ...and I am saving an image posted through a HTTP form POST...
> uploadedFile = self.request.form['upfile']
> file = open(obj.local_file_path, 'wb')
> ...immediately opening it again, to create a thumbnail...
> im = Image.open(obj.local_file_path)
> size = 256,256
> im.save('%s.thumb' % obj.local_file_path, "JPEG")
> Mvh Sebastian
> Grok-dev mailing list
> Grok-dev at zope.org
More information about the Grok-dev