illyasviel.py 文件源码

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

项目:illyasviel_bot 作者: Sg4Dylan 项目源码 文件源码
def execute_job(self):
        mode = self.get_argument("mode")
        message = self.get_argument("msg")
        thumb = self.get_argument("thumb")
        # load setting
        pos = config.images_dict[mode][2]
        font_size = config.images_dict[mode][3]
        font_color = config.images_dict[mode][4]
        filename = config.image_path + config.images_dict[mode][5]
        # gen picture
        img = Image.open(filename)
        draw = ImageDraw.Draw(img)
        font = ImageFont.truetype(config.font_path, font_size)
        imgW, imgH = img.size
        textW, textH = draw.textsize(message,font=font)
        # print(textW, textH)
        draw.text(((imgW-textW)/2,pos),message,font_color,font=font)
        # thumb
        if thumb == "1":
            img.thumbnail((300,300),Image.ANTIALIAS)
        # gen file pointer
        img_io = BytesIO()
        img.save(img_io, 'JPEG', quality=100)
        img_io.seek(0)
        # return picture
        return img_io.getvalue()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号