瀏覽代碼

Initial commit, reads the image and prints out character values

master
Noëlle Anthony 6 年之前
父節點
當前提交
eef607f296
共有 2 個檔案被更改,包括 21 行新增0 行删除
  1. 21
    0
      stitchify.py
  2. 二進制
      test.png

+ 21
- 0
stitchify.py 查看文件

@@ -0,0 +1,21 @@
from PIL import Image
from collections import defaultdict

img = Image.open('test.png')

w,h = img.size

symbols = defaultdict(str)
characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(h):
for j in range(w):
c = "".join(["{}{}".format(hex(x//16).split('x')[-1], hex(x%16).split('x')[-1]) for x in list(img.getpixel((j,i)))])
d = " "
if c in symbols.keys():
d = symbols[c]
else:
symbols[c] = characters[0]
characters = characters[1:]
d = symbols[c]
print(d, end="")
print()

二進制
test.png 查看文件


Loading…
取消
儲存