我的代码有点有线问题。我正在从表单中上传文件,该文件我得到了InMemoryUploadedFile
。
image_node = data['image_url'] # InMemoryUploadedFile
body = image_node.read()
# do whatever you like with the picture,
pil_image = Image.open(image_node) # PIL image object.
# i get error that Cannot identify image.
当我首先打开PIL时,我可以正常工作,然后image_node.read()
失败。我想我缺少一些文件对象的概念。请找到语义错误。
试试这个
image_node = data['image_url']
body = image_node.read()
# do stuff
image_node.seek(0)
pil_image = Image.open(image_node)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句