Skip to content

Commit

Permalink
fixed: 修复了Pillow更新导致的猜卡字符画无法使用的问题
Browse files Browse the repository at this point in the history
0.2.9.8->0.2.9.9
  • Loading branch information
fireinsect committed Jun 13, 2024
1 parent 9f31d5b commit b2cf235
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nonebot_plugin_ocgbot_v2/guess_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
# 切割处理
Expand Down
7 changes: 4 additions & 3 deletions nonebot_plugin_ocgbot_v2/libraries/charpic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit b2cf235

Please sign in to comment.