【问题标题】:IOError: cannot identify image fileIOError:无法识别图像文件
【发布时间】:2014-06-26 00:44:53
【问题描述】:

谁能告诉为什么 PIL 不能打开这个 PNG 文件?

https://b75094855c6274df1cf8559f089f485661ae1156.googledrive.com/host/0B56ak7W-HmqAX005c3g5eTlBakE/8.png

我得到 IOError: cannot identify image file,通过查看代码,它似乎尝试了 PIL.PngImagePlugin.PngImageFile 和相应的“accept”函数,它返回 False

我使用的是 1.1.6 版

【问题讨论】:

    标签: python-imaging-library


    【解决方案1】:

    我不知道 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 吗?
    • 我正在寻找解决同一问题的方法。到目前为止,枕头没有帮助。不过感谢您的建议。
    【解决方案2】:

    尝试导入 cv2

    >>> from PIL import Image
    >>> import cv2
    >>> im = cv2.imread("8.png")
    >>> im = cv2.imwrite("8.png")
    

    我希望它的工作...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 1970-01-01
      • 2020-05-26
      • 2017-09-11
      • 2015-09-05
      • 1970-01-01
      相关资源
      最近更新 更多