Maker-Melissa / OpenSign

A library to facilitate easy RGB Matrix Sign Animations on the Raspberry Pi using Python.
MIT License
26 stars 2 forks source link

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

Open DeeYellEm opened 9 months ago

DeeYellEm commented 9 months ago

A fresh install of OpenSign will also install the latest Pillow (v10.2.0 as of 1/27/2024). Per this reference (https://github.com/tensorflow/models/issues/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 commented 9 months ago

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