Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# coding: utf-8
import os
from PIL import Image
from glob import glob
flist = []
fhist = []
dl = []
dirname = './images/'
for e in ['png', 'jpg']: flist.extend(glob('%s/*.%s'%(dirname,e)))
for fn in flist: fhist.append(Image.open(fn).histogram())
for i in xrange(len(flist)):
if flist[i] in dl: continue
for j in xrange(i+1, len(flist)):
if flist[j] in dl: continue
if fhist[i] == fhist[j] and not flist[j] in dl:
dl.append(flist[j])
for a in dl: os.remove(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment