From 24349d5e241a662c8fd5f5a1721ec3164a4fc7e3 Mon Sep 17 00:00:00 2001 From: KimgiaiiWuyi <444835641@qq.com> Date: Mon, 13 Jun 2022 08:25:41 +0800 Subject: [PATCH] =?UTF-8?q?'=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=B8=BAb64'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- enkaToData/drawCharCard.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/enkaToData/drawCharCard.py b/enkaToData/drawCharCard.py index cc95aab4..b0b2d006 100644 --- a/enkaToData/drawCharCard.py +++ b/enkaToData/drawCharCard.py @@ -3,10 +3,11 @@ import json from io import BytesIO from pathlib import Path import string +from io import BytesIO +from base64 import b64encode from PIL import Image, ImageDraw, ImageFont from httpx import get -from nonebot import logger R_PATH = Path(__file__).parents[0] TEXT_PATH = R_PATH / 'texture2D' @@ -481,5 +482,6 @@ async def draw_char_card(raw_data: dict, charUrl: str = None) -> bytes: img = img.convert('RGB') result_buffer = BytesIO() img.save(result_buffer, format='JPEG', subsampling=0, quality=90) - res = result_buffer.getvalue() - return res + imgmes = 'base64://' + b64encode(result_buffer.getvalue()).decode() + res = imgmes + return res \ No newline at end of file