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 v10+ doesn't support getsize which breaks OpenSign #10

Open
DeeYellEm opened this issue Jan 27, 2024 · 1 comment
Open

Pillow v10+ doesn't support getsize which breaks OpenSign #10

DeeYellEm opened this issue Jan 27, 2024 · 1 comment

Comments

@DeeYellEm
Copy link

A fresh install of OpenSign will also install the latest Pillow (v10.2.0 as of 1/27/2024). Per this reference (tensorflow/models#11040), Pillow removed the getsize function. This breaks OpenSign as opensign.py uses getsize. For example:
canvas.py:204: ... font.getsize(...)
Per the above page, the recommendation is to downgrade to Pillow 9.5 which restores the getsize.

This StackOverflow post mentions how to do the equivalent using getbbox with slightly more code:
(https://stackoverflow.com/questions/77341312/easy-way-to-replace-imagefont-getsizetext-to-imagefont-textbboxtext-in-pillo)

# old way using getsize()
# text_width, text_height = font.getsize(text)
# using pillow 10+
left, top, right, bottom = font.getbbox(text)
text_width = right - left
text_height = bottom - top

The getsize function only appears once in canvas.py currently

@makermelissa
Copy link
Collaborator

Thanks. Yeah, it needs an update. Until then, I'll probably update the dependency to install 9.5.

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

2 participants