猫史档案馆


hhhhhh

用户:退坑疯癫花酱退坑疯癫花酱查看:0 回复:0 评论:0 创建时间:2020-05-17T13:43:11


from PIL import Image, ImageDraw

width, height = (60, 60)

img = Image.open("bcm.jpg").convert('L').resize((width, height))

ASCII_HIGH = '''$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. '''

txt = ''
for y in range(height):
    for x in range(width):
        pos = (x, y)
        gray = img.getpixel(pos)  
        index = int(gray / 256 * 70)
        txt += ASCII_HIGH[index] + ' '
    txt += '\n'
print(txt)


回复

上一页1 页 / 共 0下一页