controller: browser_overlays — resize screenshot к target w_px×h_px

Без resize element screenshot возвращался в native dims (e.g. Grafana panel
790×258), не fitting configured overlay slot (1280×180 = info strip). Result
— overflow + gap.

С resize (LANCZOS) PNG exactly w_px×h_px, fills slot полностью. Trade-off:
если aspect не совпадает (panel 3:1 → strip 7:1), будет растяжение
horizontal. User responsibility tune w_px/h_px к нужным пропорциям.

Verified: GPU/VRAM panel 790×258 → 1280×180 readable, lines + labels OK.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gx
2026-05-22 05:38:45 +01:00
parent fc40b5c402
commit c287caf7c1
@@ -202,6 +202,11 @@ class BrowserRenderer:
img = Image.open(io.BytesIO(screenshot_bytes))
if img.mode != "RGBA":
img = img.convert("RGBA")
# Resize к target w_px×h_px — overlay поместится exactly в configured slot.
# Без resize element скриншот возвращается в native dims (e.g. 790×258 для
# Grafana panel) → overflow / gap в slot. LANCZOS = high-quality downscale.
if img.size != (cfg.w_px, cfg.h_px):
img = img.resize((cfg.w_px, cfg.h_px), Image.LANCZOS)
path = self.icon_dir / f"{cfg.id}.png"
tmp = path.with_suffix(".png.tmp")
img.save(tmp, "PNG")