main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:Nightchord 作者: theriley106 项目源码 文件源码
def WriteToImage(output, txt, size=45, input='background.jpg'):
    output = str(output).replace('.png', '').replace('.jpg', '')
    i = Image.open(input)
    font = ImageFont.load_default()
    txt = txt.split(' ')
    r = []
    for part in txt:
        r.append(str(part).replace(' ', ''))
    txt = r
    a = ''
    while len(txt) > 0:
        try:
            for e in range(7):
                item = txt[0]
                txt.remove(item)
                a = a + ' ' + str(item)
            a = a + '\n'
        except:
            break
    text_col = (255, 255, 255) # bright green
    halo_col = (0, 0, 0)   # black
    i2 = draw_text_with_halo(i, (20, 40), a, font, text_col, halo_col)
    i2.save('{}.png'.format(output))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号