fix image2text

This commit is contained in:
HibiKier 2022-05-31 20:45:28 +08:00
parent 5534a5a5c2
commit 501e47c6ec
3 changed files with 20 additions and 12 deletions

View File

@ -243,9 +243,15 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
## 更新
### 2022/5/30
### 2022/5/31
* 商店插件判断是否有requirements.txt文件
* 修复开启/关闭全部功能时帮助图片未重绘 [@pull/721](https://github.com/HibiKier/zhenxun_bot/pull/721)
* bot_friend_group将group_handle.修改为friend_handle. [@pull/711](https://github.com/HibiKier/zhenxun_bot/pull/711)
* 修复发红包图片背景未透明化;修复原神树脂提醒参数错误 [@pull/712](https://github.com/HibiKier/zhenxun_bot/pull/712)
* 修复抽卡插件方舟更新UP池信息时若公告的第一个池子过期会导致无法更新UP池信息 [@pull/707](https://github.com/HibiKier/zhenxun_bot/pull/707)
* 商店插件判断是否有requirements.txt文件 [@pull/705](https://github.com/HibiKier/zhenxun_bot/pull/705)
* 删除原神玩家查询api返回变更的多余键值
* 优化了text2image方法
### 2022/5/29 \[v0.1.5.8]

View File

@ -182,7 +182,7 @@ def parsed_data(
role_data = {
"active_day_number": data["stats"]["active_day_number"], # 活跃天数
"achievement_number": data["stats"]["achievement_number"], # 达成成就数量
"win_rate": data["stats"]["win_rate"],
# "win_rate": data["stats"]["win_rate"],
"anemoculus_number": data["stats"]["anemoculus_number"], # 风神瞳已收集
"geoculus_number": data["stats"]["geoculus_number"], # 岩神瞳已收集
"avatar_number": data["stats"]["avatar_number"], # 获得角色数量

View File

@ -1492,23 +1492,25 @@ async def text2image(
width = 0
height = 0
_tmp = BuildImage(0, 0, font=font, font_size=font_size)
_, h = _tmp.getsize("")
line_height = int(font_size / 3)
image_list = []
for x in text.split("\n"):
if x:
w, _ = _tmp.getsize(x)
_, h = _tmp.getsize("")
height += h + _add_height
width = width if width > w else w
w, _ = _tmp.getsize(x.strip() or "")
height += h + line_height
width = width if width > w else w
image_list.append(BuildImage(w, h, font=font, font_size=font_size, plain_text=x.strip()))
width += pw
height += ph
A = BuildImage(
width + left_padding,
height + top_padding + 2,
font_size=font_size,
color=color,
font=font,
)
await A.atext((left_padding, top_padding), text, font_color)
# A.show()
cur_h = ph
for img in image_list:
await A.apaste(img, (pw, cur_h + ph), True)
cur_h += img.h + line_height
return A