Created
April 2, 2010 00:48
-
-
Save selwin/352593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
from os.path import join | |
from PIL import Image | |
#print os.path.dirname(__file__) | |
for current_directory, sub_directories, files in os.walk('.'): | |
#print "Current directory", current_directory | |
#print "Sub directories", sub_directories | |
for filename in files: | |
path = os.path.join(current_directory, filename) | |
try: | |
trial_image = Image.open(path) | |
trial_image.verify() | |
print path + ' is a valid image file' | |
except ImportError: | |
# Under PyPy, it is possible to import PIL. However, the underlying | |
# _imaging C module isn't available, so an ImportError will be | |
# raised. Catch and re-raise. | |
raise | |
except: # Python Imaging Library doesn't recognize it as an image | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment