From 39a57503b7998c98504a996923a8eca655eeb92c Mon Sep 17 00:00:00 2001 From: lowtower Date: Tue, 9 Apr 2024 20:20:30 +0200 Subject: [PATCH] Bugfix/pillow10: Not compatible with Pillow=10.0.0 #31 (#32) * open with encoding * Update draw_gpx.py * ImageDraw.textlength() instead of deprecated method ImageDraw.textsize() * use ImageDraw.textbbox() to retrieve the textbox height --------- Co-authored-by: Lowtower --- staticmaps/pillow_renderer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/staticmaps/pillow_renderer.py b/staticmaps/pillow_renderer.py index 38827bf..76dee27 100644 --- a/staticmaps/pillow_renderer.py +++ b/staticmaps/pillow_renderer.py @@ -97,9 +97,10 @@ def render_attribution(self, attribution: typing.Optional[str]) -> None: if (attribution is None) or (attribution == ""): return margin = 2 - _, th = self.draw().textsize(attribution) w = self._trans.image_width() h = self._trans.image_height() + left, top, right, bottom = self.draw().textbbox((margin, h - margin), attribution) + th = bottom - top overlay = PIL_Image.new("RGBA", self._image.size, (255, 255, 255, 0)) draw = PIL_ImageDraw.Draw(overlay) draw.rectangle([(0, h - th - 2 * margin), (w, h)], fill=(255, 255, 255, 204))