From 1cee24ce0bf179c88ec31f7ac717a7c25e9a608d Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 20 Feb 2024 21:45:48 +0000 Subject: [PATCH] Support Pillow v10 Pillow 9.5 deprecated the getsize method for fonts in favor of its new getbbox, and then getsize was removed in Pillow 10.. Adjust the call we use for captcha generation so it will continue working, and declare a requirement for the earliest forward-compatible release. Change-Id: Ib35eea077d7f8c428493ef8e4cfe00e05e580a6f --- lodgeit/lib/captcha.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lodgeit/lib/captcha.py b/lodgeit/lib/captcha.py index 85df593..9fe2b62 100644 --- a/lodgeit/lib/captcha.py +++ b/lodgeit/lib/captcha.py @@ -151,7 +151,7 @@ class TextLayer(Layer): # draw grayscale image white on black text_image = Image.new('L', image.size, 0) draw = ImageDraw.Draw(text_image) - text_size = self.font.getsize(self.text) + text_size = self.font.getbbox(self.text) x = int((image.size[0] - text_size[0]) * self.alignment[0] + 0.5) y = int((image.size[1] - text_size[1]) * self.alignment[1] + 0.5) draw.text((x, y), self.text, font=self.font, diff --git a/requirements.txt b/requirements.txt index 9070691..28b25cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,6 @@ SQLAlchemy<2.0.0 PyMySQL simplejson Babel -pillow +pillow>=9.5 pytz MarkupSafe