对于某些jpg文件,如:
使用windows图片查看器可以正常查看,但是使用Image.open(imagename)
时报OSError
.
from PIL import Image
imgname = '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
。