Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 22] invalid mode ('rb') or filename: ''

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

like image 727
matthewk Avatar asked Dec 05 '22 10:12

matthewk


1 Answers

This could work.

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

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

like image 75
Chen Zhu Avatar answered Feb 03 '23 01:02

Chen Zhu