Skip to content

Commit bb332c3

Browse files
committed
This program converts a whole image to a string, pretty nifty eh?
1 parent a05d74b commit bb332c3

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Image-Dict/convert.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from PIL import Image
2+
3+
selected_image = Image.open('image.png')
4+
pix = selected_image.load()
5+
width, height = selected_image.size
6+
output_file = open("output.txt", "a")
7+
output_file.write("[")
8+
for row in range(height):
9+
for column in range(width):
10+
red, green, blue, alpha = pix[column, row]
11+
print (str(red) + str(green) + str(blue))
12+
13+
if blue > 0:
14+
output_color = "Blue"
15+
else:
16+
output_color = "White"
17+
output_file.write("\"" + str(column) + " " + str(row) + " " + output_color + "\", ")
18+
output_file.write("]")

Image-Dict/image.png

115 KB
Loading

Image-Dict/output.txt

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)