Created
May 7, 2014 15:05
-
-
Save llimllib/ffbb87e0af9463cef977 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from PIL import Image | |
from glob import glob | |
import os | |
# pip install imagehash | |
import imagehash | |
images = {} | |
for f in glob("images/*"): | |
i = Image.open(f) | |
if i.size[0] < i.size[1]: | |
print f | |
i = i.rotate(90) | |
i.save(f) | |
# check for dupe-ish images. 5 is a sensitivity parameter; its value was | |
# determined empirically. | |
h = imagehash.average_hash(i, 5).hash.tostring() | |
if h in images: | |
print "{} is a dupe of {}? deleting.".format(f, images[h]) | |
os.unlink(f) | |
else: | |
images[h] = f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment