Created
April 1, 2014 11:16
-
-
Save AbstractBeliefs/9912032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!