3
image = Image.open(request.files["fullimage"])

returns:

IOError: cannot identify image file

and

image = Image.open(request.files["fullimage"].read())

returns:

IOError: [Errno 22] invalid mode ('rb') or filename: ''

What's the right way to do this, please?

matthewk
  • 1,771
  • 15
  • 30

2 Answers2

15

This could work.

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

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

Chen Zhu
  • 161
  • 1
  • 5
0

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 ;-)

matthewk
  • 1,771
  • 15
  • 30