diff --git a/plotid/tagplot_image.py b/plotid/tagplot_image.py index 6234ab648576346e0c8cbb1eb8ef8bc36629fa0f..1490515ef2e7d877687b80774329c812dadbf2ed 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