Answers for "python check if image is corrupted"

0

python check if image is corrupted

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
Posted by: Guest on January-20-2021

Code answers related to "python check if image is corrupted"

Python Answers by Framework

Browse Popular Code Answers by Language