In [1]:
import numpy as np
from PIL import Image, ImageDraw, ImageFont
In [2]:
img = Image.new('L', (20,20))
fnt = ImageFont.truetype('uming.ttc', 18)
ImageDraw.Draw(img).text((0,0), "郭", font=fnt, fill=255)
img
Out[2]:
In [3]:
def b(a):
    a = a.T.flatten() >= 128
    n = a @ 2**(np.array([1,2,3,7,4,5,6,8])-1)
    return chr(0x2800 + n)
In [4]:
img = np.array(img)
img = np.concatenate([img, img[:, ::-1]], axis=1)
img = np.concatenate([img, img[::-1]])
img[19]=255
img[:,19]=255
for i in range(0,img.shape[0],4):
    print ("".join(b(img[i:i+4,j:j+2]) for j in range(0,img.shape[1],2)))
⢀⣀⣀⣆⣠⢠⠤⢤⠄⢸⠀⠠⡤⠤⡄⣄⣰⣀⣀⡀
⠀⢰⣒⣒⡆⢸⠀⠂⠀⢸⠀⠀⠐⠀⡇⢰⣒⣒⡆⠀
⠀⠒⠒⡒⠒⢸⠀⠐⡄⢸⠀⢠⠂⠀⡇⠒⢒⠒⠒⠀
⠀⠒⠒⡇⠁⢸⠐⠖⠃⢸⠀⠘⠲⠂⡇⠈⢸⠒⠒⠀
⣀⣀⣙⣁⣀⣈⣀⣀⣀⣸⣀⣀⣀⣀⣁⣀⣈⣋⣀⣀
⠀⠀⣠⡀⠀⢀⠀⠀⠀⢸⠀⠀⠀⠀⡀⠀⢀⣄⠀⠀
⠀⠤⠤⡇⡀⢸⠠⠦⡄⢸⠀⢠⠴⠄⡇⢀⢸⠤⠤⠀
⠀⠤⠤⠥⠤⢸⠀⠠⠃⢸⠀⠘⠄⠀⡇⠤⠬⠤⠤⠀
⠀⠸⠭⠭⠇⢸⠀⠄⠀⢸⠀⠀⠠⠀⡇⠸⠭⠭⠇⠀
⠈⠉⠉⠏⠙⠘⠒⠚⠂⢸⠀⠐⠓⠒⠃⠋⠹⠉⠉⠁