我正在使用枕头在 python (2.7.4 - 64 位 windows 7) 中打开图像链接下载枕头在这里:http : //www.lfd.uci.edu/~gohlke/pythonlibs/ (Pillow-2.1.0. win-amd64-py2.7.exe)
但是安装后,打开图像时总是出错。例子:
import Image
import cStringIO
temp_file = open('C:\\Users\\Desktop\\images.png', 'rb+')
content = cStringIO.StringIO(temp_file.read())
image = Image.open(content)
我收到错误:
Traceback (most recent call last):
File "C:\Users\Desktop\test.py", line 7, in <module>
image = Image.open(content)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 2008, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
我该如何解决?