#!/usr/bin/env python3
"""Render banner.html at 1080x1350 CSS px, deviceScaleFactor 3 -> 3240x4050 PNG."""
from playwright.sync_api import sync_playwright
import sys

URL = 'http://localhost:8766/banner.html'
OUT = '/root/.hermes/image_cache/zrd_banner/banner_4x5.png'

with sync_playwright() as p:
    b = p.chromium.launch(args=['--no-sandbox', '--force-color-profile=srgb'])
    pg = b.new_page(viewport={'width': 1080, 'height': 1350}, device_scale_factor=3)
    pg.goto(URL, wait_until='networkidle')
    pg.wait_for_timeout(600)
    pg.screenshot(path=OUT, clip={'x': 0, 'y': 0, 'width': 1080, 'height': 1350})
    b.close()
print('saved', OUT)
