From ae23e62be8f232bf4f427d689ff8738c1255b30c Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Sat, 15 Mar 2025 21:31:49 +0000 Subject: Clean up some code & add example config --- imggen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'imggen.py') diff --git a/imggen.py b/imggen.py index cdc6314..460b432 100644 --- a/imggen.py +++ b/imggen.py @@ -1,6 +1,5 @@ from PIL import Image, ImageDraw, ImageFont import math -import printer font_bold = ImageFont.truetype("/usr/share/fonts/TTF/IosevkaSS08-Bold.ttc", 70, encoding="unic") font_norm = ImageFont.truetype("/usr/share/fonts/TTF/IosevkaSS08-Regular.ttc", 40, encoding="unic") @@ -17,7 +16,7 @@ def name(name: str): draw = ImageDraw.Draw(img) draw.text((0, 0), name, font=font_bold, fill="black") - if font_bold.getlength(name) > MAX_WIDTH: + if txt_len > MAX_WIDTH: wpercent = (MAX_WIDTH / float(img.size[0])) hsize = int((float(img.size[1]) * float(wpercent))) img = img.resize((MAX_WIDTH, hsize), Image.Resampling.LANCZOS) -- cgit v1.2.3-70-g09d2