Skip to content

Instantly share code, notes, and snippets.

@AbstractBeliefs
Created April 1, 2014 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbstractBeliefs/9912032 to your computer and use it in GitHub Desktop.
Save AbstractBeliefs/9912032 to your computer and use it in GitHub Desktop.
from PIL import Image
instring = """0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0
0 1 1 1 1 1 0 1 1 1 0 1 1 0 0 1 0 1 0 1 1 1 1 1 0
0 1 0 0 0 1 0 1 1 0 0 0 0 1 0 0 1 1 0 1 0 0 0 1 0
0 1 0 0 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 1 0 0 0 1 0
0 1 0 0 0 1 0 1 0 1 1 0 0 0 1 1 0 1 0 1 0 0 0 1 0
0 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0
0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 1
0 0 1 1 1 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 0 0 1 1 1
0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1
0 0 1 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 1 0 1 0 0
1 1 1 1 0 0 1 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 1 1 0
1 1 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0
0 0 0 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1 0 1
0 1 1 0 0 1 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0
0 1 0 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0
0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1
1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 1 1 1 0 1 0 1 1
0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 1 0
0 1 1 1 1 1 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1
0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1
0 1 0 0 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 1 0 1 0 0
0 1 0 0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 0 1 0
0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 0
0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 1 0 1 1 0 1 1 0"""
# Break string into 2D array of pixels
pixels = [line.split() for line in instring.split("\n")]
# New monochrome image
outImage = Image.new("1", (len(pixels[0]), len(pixels)))
# Fill image with our pixel array
for y in range(len(pixels)):
for x in range(len(pixels[0])):
outImage.putpixel((x,y), int(pixels[y][x]))
outImage.save("out.png", "PNG")
@dammitcoetzee
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment