【发布时间】:2014-06-26 00:44:53
【问题描述】:
谁能告诉为什么 PIL 不能打开这个 PNG 文件?
我得到 IOError: cannot identify image file,通过查看代码,它似乎尝试了 PIL.PngImagePlugin.PngImageFile 和相应的“accept”函数,它返回 False
我使用的是 1.1.6 版
【问题讨论】:
谁能告诉为什么 PIL 不能打开这个 PNG 文件?
我得到 IOError: cannot identify image file,通过查看代码,它似乎尝试了 PIL.PngImagePlugin.PngImageFile 和相应的“accept”函数,它返回 False
我使用的是 1.1.6 版
【问题讨论】:
我不知道 PIL 1.1.6 有什么问题,但我只是用最新的 Pillow 2.4.0 对其进行了测试,这很有效:
>>> from PIL import Image
>>> im = Image.open("8.png")
>>> im.show()
未维护的 PIL 和 Pillow 是一个积极维护和开发的分支。要使用 Pillow,请先卸载 PIL,然后安装 Pillow。
更多安装说明:http://pillow.readthedocs.org/en/latest/installation.html
【讨论】:
uninstall PIL, then install PIL: 你的意思是安装 Pillow 吗?
尝试导入 cv2
>>> from PIL import Image
>>> import cv2
>>> im = cv2.imread("8.png")
>>> im = cv2.imwrite("8.png")
我希望它的工作...
【讨论】: