Web Render Screenshot
by @wujiaming88
Generate ultra-high-resolution screenshots from HTML content using Playwright. Default 4x device scale factor produces crisp, pixel-perfect output ideal for...
Step 1: Create the HTML
Write a self-contained HTML file with inline CSS. Guidelines:
"PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serifoverflow: hidden on body if single-viewport capture is desiredStep 2: Take the Screenshot
Use the bundled script:
python3 scripts/screenshot.py [output.png] [options]
Or inline Python when the script cannot be invoked directly:
from playwright.sync_api import sync_playwrightwith sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(
viewport={"width": 1920, "height": 1080},
device_scale_factor=4, # 4x ultra-high res (default)
)
page.goto("file:///path/to/input.html", wait_until="networkidle")
page.wait_for_timeout(1000)
page.screenshot(path="output.png", full_page=True)
browser.close()
Step 3: Deliver
Output MEDIA: for inline delivery, or use openclaw message send with --force-document for Telegram to avoid compression.
clawhub install web-render-screenshot