Using WSGI, webob and PIL, I'm trying to use Image.open()
on a file directly from the request. However, Image.open()
always throws the exception "cannot identify image file". The image is the only field, no other POST or GET variables are used. The file is coming from a standard HTML upload form with enctype="multipart/form-data".
import Image, ImageFile
from webob import Request
def application(environ, start_response):
req = Request(environ)
req.make_body_seekable()
im = Image.open(req.body_file) # "Cannot identify image file"
im.save('testfileio.png','PNG')
My guess is I'm not loading in the uploaded image data correctly, but am not sure what the right way to do it would be.