Skip to content
Snippets Groups Projects
Commit 06c8b159 authored by Mayr, Hannes's avatar Mayr, Hannes
Browse files

Switch from textsize to textbbox, since it is deprecated in Pillow 10.

parent a3c3432d
No related branches found
No related tags found
2 merge requests!74Resolve "'ImageDraw' object has no attribute 'textsize'",!73Small documentation improvements and dependency updates
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment