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 dev
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 ...@@ -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. plot will also be copied to the directory.
""" """
__version__ = "0.3.1" __version__ = "0.3.2"
__author__ = "Institut Fluidsystemtechnik within nfdi4ing at TU Darmstadt" __author__ = "Institut Fluidsystemtechnik within nfdi4ing at TU Darmstadt"
...@@ -68,10 +68,12 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer: ...@@ -68,10 +68,12 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
# Create temporary PIL image to get correct textsize # Create temporary PIL image to get correct textsize
tmp_img = Image.new("L", (100, 100)) tmp_img = Image.new("L", (100, 100))
tmp_draw = ImageDraw.Draw(tmp_img) 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 # 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 = ImageDraw.Draw(img_txt)
draw_txt.text((0, 0), img_id, font=font, fill=color) draw_txt.text((0, 0), img_id, font=font, fill=color)
# Rotate the image by the given angle # Rotate the image by the given angle
...@@ -90,7 +92,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer: ...@@ -90,7 +92,7 @@ def tagplot_image(plotid_object: PlotOptions) -> PlotIDTransfer:
if plotid_object.qrcode: if plotid_object.qrcode:
qrcode = create_qrcode(img_id) qrcode = create_qrcode(img_id)
qrcode.thumbnail( 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( img.paste(
qrcode, qrcode,
......
...@@ -75,7 +75,7 @@ def tagplot_matplotlib(plotid_object: PlotOptions) -> PlotIDTransfer: ...@@ -75,7 +75,7 @@ def tagplot_matplotlib(plotid_object: PlotOptions) -> PlotIDTransfer:
if plotid_object.qrcode: if plotid_object.qrcode:
qrcode = create_qrcode(fig_id) qrcode = create_qrcode(fig_id)
qrcode.thumbnail( 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( fig.figimage(
qrcode, qrcode,
......
coverage==6.5.0 coverage==7.3.0
cycler==0.11.0 cycler==0.11.0
fonttools==4.38.0 fonttools==4.42.1
kiwisolver==1.4.4 kiwisolver==1.4.5
matplotlib==3.6.3 matplotlib==3.7.2
myst-parser==0.18.0 myst-parser==2.0.0
numpy==1.24.2 numpy==1.25.2
packaging==23.0 packaging==23.1
Pillow==9.4.0 Pillow==10.0.0
pyparsing==3.0.9 pyparsing==3.0.9
python-dateutil==2.8.2 python-dateutil==2.8.2
qrcode==7.4.2 qrcode==7.4.2
six==1.16.0 six==1.16.0
Sphinx==5.3.0 Sphinx==7.2.5
sphinx-autoapi==2.0.1 sphinx-autoapi==2.1.1
sphinx-rtd-theme==1.2.0 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