# Full-page PNG of a local HTML file: python screenshot.py IN.html OUT.png [width]
import sys
from playwright.sync_api import sync_playwright
src, out = sys.argv[1], sys.argv[2]
width = int(sys.argv[3]) if len(sys.argv) > 3 else 1280
with sync_playwright() as p:
b = p.chromium.launch()
pg = b.new_page(viewport={"width": width, "height": 900}, device_scale_factor=1.5)
pg.goto("file://" + src); pg.wait_for_timeout(1500)
pg.screenshot(path=out, full_page=True)
b.close()