#!/usr/bin/env python3
"""Render both banners at 2x DPR (2160px) with optimize PNG < 5MB."""
from playwright.sync_api import sync_playwright

JOBS = [
    ('http://localhost:8766/banner.html',         '/root/.hermes/image_cache/zrd_banner/b_45.png',  1080, 1350),
    ('http://localhost:8766/banner_square.html',  '/root/.hermes/image_cache/zrd_banner/b_11.png',  1080, 1080),
]

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()
