Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. from PIL import Image
  2. from string import ascii_letters, ascii_lowercase
  3. i = Image.open("challenge.x.png")
  4.  
  5. ret = [chr(x) for x in i.tobytes() if chr(x) in ascii_letters+" .,1234567890"]
  6.  
  7. rows = []
  8. for line in range(160, 481):
  9.     c = 0
  10.     cols = []
  11.     for col in range(160, 481):
  12.         pix = i.getpixel((line, col))
  13.         if not pix == (0, 0, 0):
  14.             try:
  15.                 cols.append(ret.pop(0))
  16.             except IndexError:
  17.                 cols.append(".")
  18.         else:
  19.             cols.append(".")
  20.     rows.append(cols)
  21.  
  22. with open("res.out", "w") as aaa:
  23.     aaa.write("\n".join("".join(x) for x in rows ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement