📌  相关文章
📜  python 检查图像是否损坏 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:15.587000             🧑  作者: Mango

代码示例1
from os import listdir
from PIL import Image
    
for filename in listdir('./'):
  if filename.endswith('.png'):
    try:
      img = Image.open('./'+filename) # open the image file
      img.verify() # verify that it is, in fact an image
    except (IOError, SyntaxError) as e:
      print('Bad file:', filename) # print out the names of corrupt files