将图像从 Flask 的 request.files 属性加载到 PIL Image [英] Loading image from Flask's request.files attribute into PIL Image
本文介绍了将图像从 Flask 的 request.files 属性加载到 PIL Image的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
image = Image.open(request.files["fullimage"])
返回:
IOError: 无法识别图像文件
IOError: cannot identify image file
和
image = Image.open(request.files["fullimage"].read())
返回:
IOError: [Errno 22] 无效模式 ('rb') 或文件名: ''
IOError: [Errno 22] invalid mode ('rb') or filename: ''
请问正确的做法是什么?
What's the right way to do this, please?
推荐答案
这可行.
img = Image.open(request.files['file'].stream)
也许为时已晚,但希望它可以帮助其他找到此内容的人.
Maybe it's too late, but hope it would help others who find this.
这篇关于将图像从 Flask 的 request.files 属性加载到 PIL Image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文