Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新了一下pillow库跟nb2.2.0,图片发不出来了 #103

Open
RainbowDashKira opened this issue Feb 20, 2024 · 10 comments
Open

更新了一下pillow库跟nb2.2.0,图片发不出来了 #103

RainbowDashKira opened this issue Feb 20, 2024 · 10 comments

Comments

@RainbowDashKira
Copy link

今日运势生成出错……,后台没有报错。更新前一切正常。

@smaxad47
Copy link

smaxad47 commented Mar 4, 2024

ubuntu 20.04
python 3.12.2
nonebot 2.2.1
pillow 9.5.0

一样的问题,生成出错,但是没有任何报错日志

@xiaonengya
Copy link

同上,但是我的pillow是10.2.0

@Xiao-yux
Copy link

bfebb5baec7dd4fb767a449606ee5cc0

@ElainaFanBoy
Copy link
Contributor

同问

@KafCoppelia
Copy link
Member

pillow 高版本改了一些函数的接口,参见:FreeTypeFont.getsize()

@360add
Copy link

360add commented Apr 28, 2024

pillow 高版本改了一些函数的接口,参见:FreeTypeFont.getsize()
怎么解决呀

@misaka10032w
Copy link

pillow 高版本改了一些函数的接口,参见:FreeTypeFont.getsize()
怎么解决呀

同问

我把python降级到3.10.9了,之后降级pillow到9.1.0,就正常了

@qsm-mz-hn
Copy link

pillow 高版本改了一些函数的接口,参见:FreeTypeFont.getsize()
怎么解决呀

同问

我把python降级到3.10.9了,之后降级pillow到9.1.0,就正常了

怎么我的9.1.0还是不行

@Nenot233
Copy link

pillow 高版本改了一些函数的接口,参见:FreeTypeFont.getsize()
怎么解决呀

同问

我把python降级到3.10.9了,之后降级pillow到9.1.0,就正常了

怎么我的9.1.0还是不行

pip3 install pillow==9.5.0

@WuSheng125
Copy link

如果问题是有其他插件必须依赖pillow>=10.0.0,可以考虑修改utils.py文件内如下所示的代码

    ttfront = ImageFont.truetype(fontPath["title"], font_size)
    #font_length = ttfront.getsize(title)
    font_length = ttfront.getbbox(title)
    draw.text(
        (
            #image_font_center[0] - font_length[0] / 2,
            #image_font_center[1] - font_length[1] / 2,
            image_font_center[0] - (font_length[2] - font_length[0]) / 2,
            image_font_center[1] - (font_length[3] - font_length[1]) / 2,
        ),
        title,
        fill=color,
        font=ttfront,
    )

参考:
ImageFont.getbbox()
Font size and offset methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests