From 06c8b159f060b02c80185eb4737efbed69d2c05c Mon Sep 17 00:00:00 2001 From: "Mayr, Hannes" <hannes.mayr@stud.tu-darmstadt.de> Date: Sat, 2 Sep 2023 12:26:15 +0200 Subject: [PATCH] Switch from textsize to textbbox, since it is deprecated in Pillow 10. --- plotid/tagplot_image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plotid/tagplot_image.py b/plotid/tagplot_image.py index 6234ab6..1490515 100644 --- a/plotid/tagplot_image.py +++ b/plotid/tagplot_image.py @@ -68,10 +68,12 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer: # Create temporary PIL image to get correct textsize tmp_img = Image.new("L", (100, 100)) tmp_draw = ImageDraw.Draw(tmp_img) - textsize = tmp_draw.textsize(img_id, font) + _, _, textwidth, textheight = tmp_draw.textbbox((0, 0), img_id, font) # Create new image with white background and the size of the textbox - img_txt = Image.new("RGBA", textsize, color=(255, 255, 255, 0)) + img_txt = Image.new( + "RGBA", (textwidth, textheight), color=(255, 255, 255, 0) + ) draw_txt = ImageDraw.Draw(img_txt) draw_txt.text((0, 0), img_id, font=font, fill=color) # Rotate the image by the given angle -- GitLab