From b2cf235c0e80c3866dd1cc8d7bad80bffee63e25 Mon Sep 17 00:00:00 2001 From: fireinsect <847954981@qq.com> Date: Thu, 13 Jun 2024 13:17:02 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E4=BF=AE=E5=A4=8D=E4=BA=86Pillow?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=BC=E8=87=B4=E7=9A=84=E7=8C=9C=E5=8D=A1?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E7=94=BB=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=200.2.9.8->0.2.9.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_ocgbot_v2/guess_card.py | 2 +- nonebot_plugin_ocgbot_v2/libraries/charpic.py | 7 ++++--- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nonebot_plugin_ocgbot_v2/guess_card.py b/nonebot_plugin_ocgbot_v2/guess_card.py index ab1198c..93cff26 100644 --- a/nonebot_plugin_ocgbot_v2/guess_card.py +++ b/nonebot_plugin_ocgbot_v2/guess_card.py @@ -372,7 +372,7 @@ def getGuessImg(image: Image, restrict=3) -> Image: height, weight = image.size # 模糊处理 if getRandom(restrict) == 1: - image.thumbnail((height / RESIZE, weight / RESIZE), Image.ANTIALIAS) + image.thumbnail((height / RESIZE, weight / RESIZE), Image.LANCZOS) height, weight = image.size image = image.resize((height * RESIZE, weight * RESIZE)) # 切割处理 diff --git a/nonebot_plugin_ocgbot_v2/libraries/charpic.py b/nonebot_plugin_ocgbot_v2/libraries/charpic.py index 07952f4..503a79f 100644 --- a/nonebot_plugin_ocgbot_v2/libraries/charpic.py +++ b/nonebot_plugin_ocgbot_v2/libraries/charpic.py @@ -15,11 +15,12 @@ def charPic(img: Image) -> Image: line = "" for x in range(img.width): gray = img.image.getpixel((x, y)) - line += str_map[int(num * gray / 256)] + line += str_map[int(num * gray / 256)] if gray != 0 else " " lines.append(line) text = "\n".join(lines) - w, h = font.getsize_multiline(text) - text_img = Image.new("RGB", (w, h), "white") + text_img = Image.new("RGB", (2000, 2000), "white") draw = ImageDraw.Draw(text_img) + _, _, w, h = draw.multiline_textbbox((0, 0), text, font=font) draw.multiline_text((0, 0), text, font=font, fill="black") + text_img = text_img.crop((0, 0, w, h)) return BuildImage(text_img).image diff --git a/pyproject.toml b/pyproject.toml index e26d7fb..caf7fc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nonebot-plugin-ocgbot-v2" -version = "0.2.9.8" +version = "0.2.9.9" description = "nonebot-plugin-ocgbot-v2" authors = ["fireinsect <847954981@qq.com>"] readme = "README.md"