【发布时间】:2017-02-05 08:53:12
【问题描述】:
在此处遵循 XlsxWriter 指南: Docs 我尝试使用 Pillow 来获取 png 文件。然后使用上面链接中的指南写入工作表。我尝试使用 StringIO。
f = Image.open('/opt/folder/' + 'cc.png')
output = StringIO.StringIO(f)
f.save(output)
f = output.getvalue()
output.close()
frontSheet.insert_image('B1', f, {'x_scale': 0.5, 'y_scale': 0.5})
错误信息说 NoneType 对象是不可调用的。
cc = Image.open('/opt/folder/' + 'cc.png')
f = cStringIO.StringIO(Image.open('/opt/folder/' + 'cc.png'))
cc.save(im2, 'PNG')
frontSheet.insert_image('B1', cc, {'x_scale': 0.5, 'y_scale': 0.5}
错误消息说它无法识别图像文件。如何将 png 文件写入工作表?
【问题讨论】:
-
有什么建议吗? @jmcnamara
标签: image python-2.7 pillow xlsxwriter stringio