You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stitchify.py 478B

12345678910111213141516171819
  1. from PIL import Image
  2. from collections import defaultdict
  3. img = Image.open('test.png')
  4. w,h = img.size
  5. symbols = defaultdict(str)
  6. characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  7. for i in range(h):
  8. for j in range(w):
  9. c = "".join(["{}{}".format(hex(x//16).split('x')[-1], hex(x%16).split('x')[-1]) for x in list(img.getpixel((j,i)))])
  10. d = " "
  11. if c not in symbols.keys():
  12. symbols[c] = characters[0]
  13. characters = characters[1:]
  14. d = symbols[c]
  15. print(d, end="")
  16. print()