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

Merge branch '139-imagedraw-object-has-no-attribute-textsize' into 'dev'

Resolve "'ImageDraw' object has no attribute 'textsize'"

See merge request !74
parents a3c3432d 87282c96
Branches
Tags
2 merge requests!74Resolve "'ImageDraw' object has no attribute 'textsize'",!73Small documentation improvements and dependency updates
Pipeline #1064368 passed
......@@ -10,5 +10,5 @@ research data, the plot is based on. Additionally, the script that created the
plot will also be copied to the directory.
"""
__version__ = "0.3.1"
__version__ = "0.3.2"
__author__ = "Institut Fluidsystemtechnik within nfdi4ing at TU Darmstadt"
......@@ -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
......@@ -90,7 +92,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
if plotid_object.qrcode:
qrcode = create_qrcode(img_id)
qrcode.thumbnail(
(plotid_object.qr_size, plotid_object.qr_size), Image.ANTIALIAS
(plotid_object.qr_size, plotid_object.qr_size), Image.Resampling.LANCZOS
)
img.paste(
qrcode,
......
......@@ -75,7 +75,7 @@ def tagplot_matplotlib(plotid_object: PlotOptions) -> PlotIDTransfer:
if plotid_object.qrcode:
qrcode = create_qrcode(fig_id)
qrcode.thumbnail(
(plotid_object.qr_size, plotid_object.qr_size), Image.ANTIALIAS
(plotid_object.qr_size, plotid_object.qr_size), Image.Resampling.LANCZOS
)
fig.figimage(
qrcode,
......
coverage==6.5.0
coverage==7.3.0
cycler==0.11.0
fonttools==4.38.0
kiwisolver==1.4.4
matplotlib==3.6.3
myst-parser==0.18.0
numpy==1.24.2
packaging==23.0
Pillow==9.4.0
fonttools==4.42.1
kiwisolver==1.4.5
matplotlib==3.7.2
myst-parser==2.0.0
numpy==1.25.2
packaging==23.1
Pillow==10.0.0
pyparsing==3.0.9
python-dateutil==2.8.2
qrcode==7.4.2
six==1.16.0
Sphinx==5.3.0
sphinx-autoapi==2.0.1
sphinx-rtd-theme==1.2.0
Sphinx==7.2.5
sphinx-autoapi==2.1.1
sphinx-rtd-theme==1.3.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment