From anonymous, 2 Weeks ago, written in Python.
Embed
  1. ### process.py
  2.  
  3. #!/usr/bin/python
  4.  
  5. import pickle
  6. import glob
  7. import collections
  8.  
  9. import PIL.Image
  10.  
  11.  
  12. data = collections.defaultdict(list)
  13.  
  14.  
  15. for fn in sorted(glob.glob('*.png')):
  16.     print(fn)
  17.     img = PIL.Image.open(fn)
  18.     colors = img.getcolors()
  19.     data[tuple(colors)].append(fn)
  20.  
  21.  
  22. with open('data.pickle', 'wb') as f:
  23.     pickle.dump(data, f)
  24.  
  25.  
  26. ### analyze.py
  27.  
  28. import pickle
  29. from pprint import pprint
  30.  
  31.  
  32. with open('data.pickle', 'rb') as f:
  33.     data = pickle.load(f)
  34.  
  35. stats = {k: len(v) for k, v in data.items()}.items()
  36.  
  37. pprint(list(reversed(sorted(stats, key=lambda i: i[1]))))
  38.