From 875f0d26512f6e83f3a26937aa4a8941cdfd4e50 Mon Sep 17 00:00:00 2001 From: Amit Sharma Date: Wed, 16 Aug 2023 12:04:03 +0530 Subject: [PATCH] `TypeError: cannot unpack non-iterable float object` --- plugins/logo.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/plugins/logo.py b/plugins/logo.py index 032914e893..127a36c088 100644 --- a/plugins/logo.py +++ b/plugins/logo.py @@ -87,19 +87,11 @@ async def logo_func(event): class LogoHelper: - @staticmethod - def get_text_size(text, image, font): - im = Image.new("RGB", (image.width, image.height)) - draw = ImageDraw.Draw(im) - return draw.textlength(text, font) - @staticmethod def find_font_size(text, font, image, target_width_ratio): tested_font_size = 100 tested_font = ImageFont.truetype(font, tested_font_size) - observed_width, observed_height = LogoHelper.get_text_size( - text, image, tested_font - ) + observed_width, observed_height = tested_font.getsize(text) estimated_font_size = ( tested_font_size / (observed_width / image.width) * target_width_ratio @@ -118,7 +110,7 @@ def make_logo(imgpath, text, funt, **args): draw = ImageDraw.Draw(img) font_size = LogoHelper.find_font_size(text, funt, img, width_ratio) font = ImageFont.truetype(funt, font_size) - w, h = draw.textlength(text, font=font) + w, h = font.getsize(text) draw.text( ((width - w) / 2, (height - h) / 2), text,