Affichage paysage: canevas 1680x1264, rotation 90deg, layout 2 colonnes

This commit is contained in:
jerem
2026-06-15 14:33:05 +02:00
parent d75872c065
commit 56f71c0ea6
4 changed files with 112 additions and 83 deletions

View File

@@ -1,4 +1,5 @@
"""Construit le contexte, rend le HTML puis le capture en PNG niveaux de gris (1264x1680)."""
"""Construit le contexte, rend le HTML en paysage (1680x1264) puis le capture en PNG
niveaux de gris, pivoté de 90° pour le panneau e-ink portrait (1264x1680)."""
from __future__ import annotations
import asyncio
@@ -98,6 +99,10 @@ async def render_png() -> bytes:
# Conversion niveaux de gris (mode 'L') -> e-ink friendly, fichier plus léger.
img = Image.open(io.BytesIO(png_bytes)).convert("L")
# Le canevas est rendu en paysage (1680x1264) ; on pivote de 90° pour le panneau
# e-ink physiquement en portrait. "cw" = bouton à droite (rotation horaire).
rota = Image.ROTATE_270 if config.rotate == "cw" else Image.ROTATE_90
img = img.transpose(rota)
out = io.BytesIO()
img.save(out, format="PNG", optimize=True)
return out.getvalue()