From 7440e9e5d256233593e4da1b4f7b8293628685ac Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Sat, 4 Mar 2023 21:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(blob.py):=20=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/qqbot/blob.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/qqbot/blob.py b/pkg/qqbot/blob.py index 5b833346..2ac6a4b4 100644 --- a/pkg/qqbot/blob.py +++ b/pkg/qqbot/blob.py @@ -45,16 +45,16 @@ def text_to_image(text: str) -> MessageComponent: os.mkdir('temp') img_path = text2img.text_to_image(text_str=text, save_as='temp/{}.png'.format(int(time.time()))) - compressed = text2img.compress_image(img_path, outfile="temp/{}_compressed.png".format(int(time.time()))) + compressed_path, size = text2img.compress_image(img_path, outfile="temp/{}_compressed.png".format(int(time.time()))) # 读取图片,转换成base64 - with open(img_path, 'rb') as f: + with open(compressed_path, 'rb') as f: img = f.read() b64 = base64.b64encode(img) # 删除图片 os.remove(img_path) - os.remove(compressed) + os.remove(compressed_path) # 返回图片 return Image(base64=b64.decode('utf-8'))