From 1587c07e5d028c4c9b8876f4387e0168f2356687 Mon Sep 17 00:00:00 2001 From: Noah Axon Date: Wed, 9 Aug 2023 17:26:09 -0500 Subject: [PATCH] Fix 2 calls deprecated in Py-Pillow 10 --- heatmap/heatmap.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/heatmap/heatmap.py b/heatmap/heatmap.py index e67cb01..da83b17 100644 --- a/heatmap/heatmap.py +++ b/heatmap/heatmap.py @@ -467,12 +467,12 @@ def closest_index(n, m_list, interpolate=False): def word_aa(label, pt, fg_color, bg_color): f = ImageFont.truetype(vera_path, pt*3) - s = f.getsize(label) - s = (s[0], pt*3 + 3) # getsize lies, manually compute + left, top, right, bottom = f.getbbox(label) + s = (right - left, pt*3 + 3) # getsize lies, manually compute w_img = Image.new("RGB", s, bg_color) w_draw = ImageDraw.Draw(w_img) w_draw.text((0, 0), label, font=f, fill=fg_color) - return w_img.resize((s[0]//3, s[1]//3), Image.ANTIALIAS) + return w_img.resize((s[0]//3, s[1]//3), Image.Resampling.LANCZOS) def blend(percent, c1, c2): "c1 and c2 are RGB tuples" @@ -623,3 +623,4 @@ def create_labels(args, img): print("saving") img.save(args.output_path) +