1
0
Fork 0
forked from zovos/bot_tg

add second maket

This commit is contained in:
q 2026-03-05 12:30:17 +03:00
parent 6afc30570f
commit f14b1a8209
3 changed files with 12 additions and 2 deletions

View file

@ -26,6 +26,12 @@ TEMPLATES = {
"padding": 20,
"label": "Владимир Владимирович Путин самый лучший президент",
},
"2": {
"path": BASE_DIR / "maket" / "2.png",
"anchor": (40, 40),
"box_size": (582, 346),
"label": "Макет 2",
},
}
# --- Расписание ---

View file

@ -262,7 +262,11 @@ def generate_maket(text: str, template_id: str = "1") -> BytesIO:
raise FileNotFoundError(f"Шаблон {template_id} не найден")
with Image.open(tpl["path"]).convert("RGB") as img:
anchor, padding = tpl["anchor"], tpl["padding"]
anchor = tpl["anchor"]
if "box_size" in tpl:
max_w, max_h = tpl["box_size"]
else:
padding = tpl.get("padding", 0)
max_w, max_h = img.width - anchor[0] - padding, img.height - anchor[1] - padding
font, lines, stroke, spacing = fit_text_in_box(text, max_w, max_h)

BIN
maket/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 KiB