您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

字符图片代码(python)

2023/8/6 12:33:44发布29次查看
字符图片代码(python)
def rgb _ xunzhaoteyidian(file pathbject,t) -&gt。对象:
原点_img =图像。打开(文件路径)
#收缩后的宽度和高度
resize _ width = int(origin _ img . size[0]/6)
resiz最好看的都市小说e _ height = int(origin _ img . size[1]/6)
调整大小(调整大小_宽度,调整大小_凡间狱无错版高度),图像。抗锯齿)。转换(& # 34;l & # 34(
# 2,创建新的空白色图片(灰度模式,宽度和高度与原始图片相同)
新图像。l & # 34,origin_img.size,255)
draw_obj = imagedraw。绘图(新_img)
字体=图像字体. truetype(& # 34;arial.ttf & # 34,5)
# 3。在8*8的区域内画出每个字符
对于范围内的i(resize _ height):
对于范围内的j(resize _ width):
x,y = j * 6,i * 6
temp = resize_img.getpixel((j,i))
如果210 >temp&gt。170:
draw_obj.text((x,y),& # 34;。& # 34;,font=font,fill=0)
elif 255&gt。=temp&gt。=210:
draw_obj.text((x,y),& # 34;# & # 34;,font=font,fill=0)
elif 120&gt。=temp&gt。60:
draw_obj.text((x,y),& # 34;$ & # 34;,font=font,fill=0)
elif 170 &gt。= temp &gt。120:
draw_obj.text((x,y),& # 34;?& # 34;,font=font,fill=0)
否则:
draw_obj.text((x,y),& # 34;* & # 34;,font=font,fill=0)
new _ img . save(& # 34;e:\\魔鬼侠\ \ www \ \ & # 34+str(t)+& # 34;。巴布亚新几内亚& # 34;(
/video/bv1cc4y1p7tz
文章来源:www.atolchina.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product