diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2025-03-15 21:31:49 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2025-03-15 21:31:49 +0000 |
| commit | ae23e62be8f232bf4f427d689ff8738c1255b30c (patch) | |
| tree | 5e871eb0d39be2f0c7ebe69959b3b4d4517daa88 /imggen.py | |
| parent | 932a17ad8375940ef5840bc3d6f0359ba0e9150e (diff) | |
Clean up some code & add example config
Diffstat (limited to 'imggen.py')
| -rw-r--r-- | imggen.py | 3 |
1 files changed, 1 insertions, 2 deletions
@@ -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) |
