Image.open()报错,提示 image file is truncated (XX bytes not processed)

来源:互联网 发布:淘宝规定卖家发货时间 编辑:程序博客网 时间:2024/05/29 19:06

在处理图片数据的时候,如果Image.open()报错,就不保存图片,

from PIL import Imagetry:    img = Image.open(imgname)    img.save(save_name)except:    continue

结果在读取处理后的图片的时候,还是报错,提示
image file is truncated (XX bytes not processed)

参考image file is truncated (41 bytes not processed)解决方法,

加上:

from PIL import ImageFileImageFile.LOAD_TRUNCATED_IMAGES = True
阅读全文
0 0