我试图处理由信使平台的API,提供了这个图像(发送-API参考)过程透过Facebook Messenger网址图像
@app.route('/photobot/<path:photo_url>')
def tensor_photobot(photo_url):
file = cStringIO.StringIO(urllib.urlopen(photo_url).read())
img = Image.open(file)
if img:
list_elements = process_image(img)
return json.dumps(list_elements)
但图像无法识别。任何想法?
消息:
{u'mid': u'mid.$cAAbv-uhIfdVkIn9OVld8TqA6u2Hz', u'seq': 40125, u'attachments': [{u'type': u'image', u'payload': {u'url': u' https://scontent-lht6-1.xx.fbcdn.net/v/t34.0-12/20916840_10214193209010537_198030613_n.jpg?_nc_ad=z-m&oh=3eab9a3a400c7e05fb5b74c391852426&oe=5998B9A8 '}}]}
[Reference][1] python 2.x
[1]: https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment
编辑:如下评论建议,我发现这个问题是从URL字符串截断。
我添加了更多上下文的所有实现。
你有什么错误? – amuramoto
IOError:无法识别图像文件 –
如何导入图像?这似乎是一个常见的错误,其中或者用户不使用Pillow,或者不是用'从PIL导入图像'导入Image'导入[请参阅本文](https://stackoverflow.com/questions/ 19230991 /图像开放不能-识别图像文件的Python)。 – amuramoto