This is the python script i came up with to check if an image is valid/corrupt. It is quite useful if you want to check large number of downloaded images to be valid images or corrupt images. I just open an image using PIL python module. If its a valid image, it gets opened normally otherwise an exception is raised.
It gets the job done.
It gets the job done.
import glob from PIL import Image for filename in glob.glob("*.jpg"): try: im=Image.open(filename,'r') pass except: print "error in"+filename a=open('error_report1','a'); a.write(filename) a.write("\n");
No comments:
Post a Comment