#!/usr/bin/env python3
"""Render banner_square.html at 1080x1080 CSS px, deviceScaleFactor 3 -> 3240x3240 PNG."""
from playwright.sync_api import sync_playwright

URL = 'http://localhost:8766/banner_square.html'
OUT = '/root/.hermes/image_cache/zrd_banner/banner_1x1.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': 1080}, 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': 1080})
    b.close()
print('saved', OUT)
