我在使用 PIL 包读取 JPEG 图片,有时会报如下 UserWarning:
UserWarning: Possibly corrupt EXIF data. Expecting to read 8 bytes but only got 0. Skipping tag 41730
" Skipping tag %s" % (size, len(data), tag))
UserWarning: Corrupt EXIF data. Expecting to read 12 bytes but only got 6.
warnings.warn(str(msg))
我想定位出现该问题的图片,所用代码如下:
from PIL import Image
def path2image(x):
try:
result = Image.open(x).convert("RGB")
return result
except:
print(x)
可是这样并不会运行 except 部分,求问要怎么做