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

getsize in PIL dosen't work anymore #17

Open
AvivHamagniv69 opened this issue Nov 25, 2022 · 1 comment
Open

getsize in PIL dosen't work anymore #17

AvivHamagniv69 opened this issue Nov 25, 2022 · 1 comment

Comments

@AvivHamagniv69
Copy link

in /ASCII-generator/utils.py at char_width, char_height = font.getsize("A") PIL says getsize is deprecated and will be replcaed in PIL 10, error message:

DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead.
  char_width, char_height = font.getsize(sample_character)

how to replicate the error:

python3 img2img.py --language chinese

i don't understand PIL a lot and i couldn't find what getsize does so hopefully someone else can fix this.

@quark67
Copy link

quark67 commented Feb 19, 2024

Replace char_width, char_height = font.getsize("A") with:

char_bbox = font.getbbox("A")
char_width = char_bbox[2] - char_bbox[0]
char_height = char_bbox[3]

It's really char_height = char_bbox[3], not char_height = char_bbox[3] - char_bbox[1] nor char_height = char_bbox[1] - char_bbox[3] which gives a negative number.

Source: python-pillow/Pillow#7802

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