Skip to content

Instantly share code, notes, and snippets.

@cabreraalex
Last active August 29, 2015 14:01
Show Gist options
  • Save cabreraalex/bf9d7d2da10ff6515abf to your computer and use it in GitHub Desktop.
Save cabreraalex/bf9d7d2da10ff6515abf to your computer and use it in GitHub Desktop.
Simple script which reads an image of white and black tiles and converts it into ASCII
from PIL import Image
import binascii
i = Image.open("flag.png")
x = 0
y = 0
answer = ""
for x in range(0,361,20):
for y in range(0,361,20):
if i.getpixel((y,x))[0] == 0:
answer += "1"
else:
answer += "0"
for i in range(0, len(answer), 8):
print(chr(int(answer[i:i + 8], 2)), end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment