From bdd127a2761c4588dc5361894fe1c44748e60291 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sat, 27 Jan 2024 14:26:00 +0000 Subject: [PATCH] captca.py: Fix PIL 10 support again Bug: T354099 Follows-Up: Ia17157d45995b78c6a73f844dfe7d20d09564748 Change-Id: I9d1fe7ad7f12fd79c960574daf79e558d88cb02c --- captcha.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/captcha.py b/captcha.py index c263e802b..80689ef69 100644 --- a/captcha.py +++ b/captcha.py @@ -115,7 +115,12 @@ def gen_captcha(text, fontname, fontsize, file_name): font=font, fill=fgcolor, ) - offset += font.getsize(c)[0] - random.uniform(5, 6) + if IMAGEFONT_HAS_GETBBOX: + offset += font.getbbox(c)[2:][0] + else: + offset += font.getsize(c)[0] + + offset -= random.uniform(5, 6) for i in range(10): d.arc(