猫史档案馆


【Python作品分享】字画【作品秀】

用户:Undertale哥只是个传说Undertale哥只是个传说查看:0 回复:2 评论:0 创建时间:2019-08-24T21:43:12


【作品展示】

center_image

 

【作品介绍】

from PIL import Image, ImageDraw

import matplotlib.pyplot as ink

a, b = (60, 60)

IMG = Image.open("bcm.jpg").convert('L').resize((a, b))

ink.rcParams['image.cmap'] = 'gray'

#Asn = '''@B%8&WM#*o'''

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

txt = ''

for y in range(b):

for x in range(a):

posb = (x, y)

g = IMG.getpixel(posb)

infh = int(g/256*10)

txt += Asn[infh] + " "

txt += '\n'

img_nd = Image.new('RGB',(a*12

 

【作品源代码】

from PIL import Image, ImageDraw
import matplotlib.pyplot as ink
a, b = (60, 60)

IMG = Image.open("bcm.jpg").convert('L').resize((a, b))
ink.rcParams['image.cmap'] = 'gray'

#Asn = '''@B%8&WM#*o'''
Asn = '''$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^`'. '''
txt = ''
for y in range(b):
    for x in range(a):
        posb = (x, y)
        g = IMG.getpixel(posb)
        infh = int(g/256*10)
        txt += Asn[infh] + " "
    txt += '\n'
    img_nd = Image.new('RGB',(a*12,b*15),'white')
    des = ImageDraw.Draw(img_nd)
    des.text((0,0),txt,fill='black')
    img_nd.resize((a*12,b*12)).save("好啊.jpg")

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
QBZ_QBZ_

不就是字符画吗?用pillow还可以做浮雕

点赞0


评论


QBZ_QBZ_

center_image

点赞0


评论