#!/usr/bin/env python3
"""Render 16:9 and 9:16 banners, 2x DPR, optimize PNG."""
from playwright.sync_api import sync_playwright

JOBS = [
    ('http://localhost:8766/banner_169.html', '/root/.hermes/image_cache/zrd_banner/b_169.png', 1920, 1080),
    ('http://localhost:8766/banner_916.html', '/root/.hermes/image_cache/zrd_banner/b_916.png', 1080, 1920),
]

with sync_playwright() as p:
    b = p.chromium.launch(args=['--no-sandbox', '--force-color-profile=srgb'])
    for url, out, w, h in JOBS:
        pg = b.new_page(viewport={'width': w, 'height': h}, device_scale_factor=2)
        pg.goto(url, wait_until='networkidle')
        pg.wait_for_timeout(500)
        pg.screenshot(path=out, clip={'x': 0, 'y': 0, 'width': w, 'height': h})
        pg.close()
        print('saved', out)
    b.close()
