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 10.0.0 has no font.getsize() #7322

Closed
JupyterJones opened this issue Aug 6, 2023 · 3 comments
Closed

Pillow 10.0.0 has no font.getsize() #7322

JupyterJones opened this issue Aug 6, 2023 · 3 comments

Comments

@JupyterJones
Copy link

JupyterJones commented Aug 6, 2023

I had pillow 10.0.0 I removed it and installed pillow==9.0.1 and that fixed it. Pillow 10 has no getsize()

from PIL import ImageFont
font = ImageFont.truetype("/home/jack/fonts/DejaVuSans-Bold.ttf", 41)
width, height = font.getsize("pharetra. purus")
print(width, height)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 3
      1 from PIL import ImageFont
      2 font = ImageFont.truetype("/home/jack/fonts/DejaVuSans-Bold.ttf", 41)
----> 3 width, height = font.getsize("pharetra. purus")
      4 print(width, height)

AttributeError: 'FreeTypeFont' object has no attribute 'getsize'
@radarhere
Copy link
Member

Hi. This was actually deliberately removed. See https://pillow.readthedocs.io/en/stable/releasenotes/10.0.0.html#font-size-and-offset-methods for information about what you can use instead.

@radarhere radarhere changed the title pillow 10 has no font.getsize() Pillow 10 has no font.getsize() Aug 6, 2023
@radarhere
Copy link
Member

So in this case, it would be

from PIL import ImageFont
font = ImageFont.truetype("/home/jack/fonts/DejaVuSans-Bold.ttf", 41)
left, top, right, bottom = font.getbbox("pharetra. purus")
width = right - left
height = bottom - top
print(width, height)

@python-pillow python-pillow deleted a comment from JupyterJones Aug 6, 2023
@radarhere radarhere changed the title Pillow 10 has no font.getsize() Pillow 10.0.0 has no font.getsize() Aug 6, 2023
@github-actions github-actions bot added the Stale label Aug 14, 2023
@github-actions
Copy link

Closing this issue as no feedback has been received.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2023
chris34 added a commit to inyokaproject/inyoka that referenced this issue Aug 26, 2023
link2xt added a commit to deltachat/mailadm that referenced this issue Sep 6, 2023
link2xt added a commit to deltachat/mailadm that referenced this issue Sep 6, 2023
link2xt added a commit to deltachat/mailadm that referenced this issue Sep 6, 2023
jbesq-ml added a commit to jbesq-ml/keras-ocr that referenced this issue Aug 30, 2024
python-pillow/Pillow#7322

change .getsize to get bbox because pillow changed the call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants