【发布时间】:2014-10-14 15:43:34
【问题描述】:
我正在编写一个脚本来调整图像大小,然后将其上传到 Imgur - 但我不想将图像保存在磁盘上!
fp = requests.get(link_of_image)
img = StringIO.StringIO(fp.content)
image = Image.open(img)
im2 = image.resize((50, 50), Image.ANTIALIAS)
temp = StringIO.StringIO()
im2.save(temp, 'png')
temp.seek(0)
j1 = requests.post(
url,
headers = headers,
data = {
'key': api_key,
'image': temp.read(),
'type': 'base64',
'name': '1.png',
'title': 'Picture no. 1'
}
)
运行此脚本后,我收到错误Image format not supported, or image is corrupt
【问题讨论】:
标签: python python-imaging-library imgur