Skip to content Skip to sidebar Skip to footer

Loading Image From Flask's Request.files Attribute Into Pil Image

image = Image.open(request.files['fullimage']) returns: IOError: cannot identify image file and image = Image.open(request.files['fullimage'].read()) returns: IOError: [Errno

Solution 1:

This could work.

img = Image.open(request.files['file'].stream)

Maybe it's too late, but hope it would help others who find this.

Solution 2:

I knew this would happen: in trying to put together a simple testcase, I have found the problem and fixed it. It was failing because before the line that tries to load it into the Image, I was doing other stuff, including:

request.files["fullimage"].read()

Without that, it worked fine. Adding:

request.files["fullimage"].seek(0)

between that and the line that loads it into the Image fixed the problem. I mean, I have another problem now, but I'll post that separately ;-)

Post a Comment for "Loading Image From Flask's Request.files Attribute Into Pil Image"