pillow.Image.open() 对某些jpg文件报OSError

来源:互联网 发布:ipad淘宝网图片打不开 编辑:程序博客网 时间:2024/06/05 23:58

对于某些jpg文件,如:
这里写图片描述
使用windows图片查看器可以正常查看,但是使用Image.open(imagename)时报OSError.

from PIL import Imageimgname = 'test.jpg'img = Image.open(imgname)# OSError: cannot identify image file 'test.jpg'

参考PIL的API,Image.open(),

Raises:
IOError – If the file cannot be found, or the image cannot be opened and identified.

github 上issueBug: “IOError: cannot identify image file” with some JPG images #630,
如果jpg文件的头部不在jprg market table中,则会报OSError

阅读全文
0 0
原创粉丝点击