From eca355694885560f7018b25c97ef3ce7202d9d67 Mon Sep 17 00:00:00 2001 From: Adam Erispaha Date: Wed, 22 Nov 2023 15:17:40 -0500 Subject: [PATCH] bump pillow version and update reference to its api were necessary --- requirements.txt | 2 +- swmmio/graphics/drawing.py | 6 +++--- swmmio/graphics/utils.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6b17292..928656f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ # Build dependencies pytest -pillow>=6.2.0,<10.0.0 +Pillow==10.1.0 numpy>=1.16.4 pandas>=0.24.2 pyshp==2.1.0 diff --git a/swmmio/graphics/drawing.py b/swmmio/graphics/drawing.py index 3721312..10fc9fb 100644 --- a/swmmio/graphics/drawing.py +++ b/swmmio/graphics/drawing.py @@ -217,8 +217,7 @@ def annotate_timestamp(draw): fnt = ImageFont.truetype(FONT_PATH, int(20 * scale)) timestamp = strftime("%b-%d-%Y %H:%M:%S") - txt_height = draw.textsize(timestamp, fnt)[1] - txt_width = draw.textsize(timestamp, fnt)[0] + txt_width = draw.textlength(timestamp, fnt) xy = (size[0] - txt_width - 10, 15) draw.text(xy, timestamp, fill=grey, font=fnt) @@ -228,7 +227,8 @@ def annotate_details(txt, draw): scale = 1 * size[0] / 2048 fnt = ImageFont.truetype(FONT_PATH, int(20 * scale)) - txt_height = draw.textsize(txt, fnt)[1] + _, top, _, bottom = draw.textbbox((0, 0), txt, fnt) + txt_height = top - bottom draw.text((10, size[1] - txt_height - 10), txt, fill=black, font=fnt) diff --git a/swmmio/graphics/utils.py b/swmmio/graphics/utils.py index 70ddf95..915e27f 100644 --- a/swmmio/graphics/utils.py +++ b/swmmio/graphics/utils.py @@ -10,7 +10,7 @@ def save_image(img, img_path, antialias=True, auto_open=False): imgSize = (img.getbbox()[2], img.getbbox()[3]) if antialias: size = (int(imgSize[0] * 0.5), int(imgSize[1] * 0.5)) - img.thumbnail(size, Image.ANTIALIAS) + img.thumbnail(size, Image.LANCZOS) img.save(img_path) if auto_open: