Diving-Fish / mai-bot

Based on nonebot, a common bot framework for maimai.
MIT License
301 stars 90 forks source link

pillow10库在(2023-07-01)发布的新版本中移除了textsize()函数,新项目可能出现兼容性问题 #53

Closed Rouphy closed 1 month ago

Rouphy commented 1 month ago

测试时间:2024-08-22 问题描述:获取b50的时候会报错AttributeError: 'ImageDraw' object has no attribute 'textsize' 报错的文件路径:src\libraries\maimai_best_50.py 行数:line 327 依赖包:pillow-10.4.0 备注:pillow库的官方建议是改用textbbox or textlength 附代码及报错截图 script log

Rouphy commented 1 month ago

一个不用降级pillow的办法是将第327行换成

bbox = shougouDraw.textbbox((0, 0), playCountInfo, font2)
playCountInfoW = bbox[2] - bbox[0]
playCountInfoH = bbox[3] - bbox[1]

同时将第328行换成

textPos = ((shougouImgW - playCountInfoW - font2.getbbox(playCountInfo)) / 2, 5)

因为textsize()和getoffest() are both out of date. 我写了一个b40和b50改好的版本希望可以直接push

Diving-Fish commented 1 month ago

发pr好了

Rouphy commented 1 month ago

发pr好了

感谢鱼佬,pr发了