【问题标题】:Cannot determine type of file无法确定文件类型
【发布时间】:2014-03-16 12:46:24
【问题描述】:

您好,我刚刚开始学习使用 python 进行图像处理。 当我试图打开从网上下载的图像时,我不断收到此错误,我不知道如何解决它。谁能帮我解决这个问题?

>>> dna=mahotas.imread('dna.jpeg')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 773, in imread
    img = read(filename)
  File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 444, in read
    bitmap = _read_bitmap(filename, flags)
  File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 490, in _read_bitmap
    'mahotas.freeimage: cannot determine type of file %s' % filename)
ValueError: mahotas.freeimage: cannot determine type of file dna.jpeg

【问题讨论】:

  • 能否请您正确格式化您的代码,以便更好地阅读?这会增加您获得好答案的机会。
  • 您确定 dna.jpeg 是有效的 jpeg 吗?尝试从 mspaint 创建一个测试 .bmp。

标签: python mahotas


【解决方案1】:

您好,这看起来像是一个很老的线程,但我最近发现了它,因为我遇到了同样的问题。

我认为该错误消息具有误导性,因为它暗示文件类型不正确。

我通过包含图像文件的完整路径解决了这个问题。例如,它可能看起来像:

dna = mahotas.imread('C:\Documents\dna.jpeg')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-23
    • 1970-01-01
    • 2017-05-03
    • 2019-05-31
    • 1970-01-01
    • 2023-04-07
    • 2014-01-10
    相关资源
    最近更新 更多