watermark.py 文件源码

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

项目:wxBot 作者: kzx1025 项目源码 文件源码
def text2img(text, font_color="Blue", font_size=25):
    """????? TEXT ???"""

    font = ImageFont.truetype('data/simsun.ttc', font_size)
    #??????
    text = text.split('\n')
    mark_width = 0
    for  i in range(len(text)):
        (width, height) = font.getsize(text[i])
        if mark_width < width:
            mark_width = width
    mark_height = height * len(text)

    #??????
    mark = Image.new('RGBA', (mark_width,mark_height))
    draw = ImageDraw.ImageDraw(mark, "RGBA")
    draw.setfont(font)
    for i in range(len(text)):
        (width, height) = font.getsize(text[i])
        draw.text((0, i*height), text[i], fill=font_color)
    return mark
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号