Create professional, mobile-friendly infographic images from structured content using HTML + Playwright screenshot.
Article/Content → Extract Key Points → Design HTML → Screenshot (3x) → Deliver PNG
Analyze the source material and identify:
Keep text concise — infographics are scannable, not readable. If a section needs more than 3 short lines, split it.
Create a single self-contained HTML file (no external dependencies). Read {baseDir}/references/design-system.md for the full color palette, typography, and component library.
Page setup:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
width: 750px;
background: #faf6f0;
font-family: -apple-system, 'PingFang SC', 'Noto Sans SC', sans-serif;
padding: 44px 40px;
}
</style>
</head>
Key rules:
750px (renders to 2250px at 3x — optimal for mobile)12px (renders to 36px physical pixels at 3x)#faf6f0 (cream) or #fff — never transparent — no external files, no Google Fonts CDN-apple-system, 'PingFang SC', 'Noto Sans SC', sans-serifLayout pattern (adapt to content):
Use the design system reference for exact colors, spacing, and component HTML.
Use the bundled screenshot script:
node {baseDir}/scripts/screenshot.js /tmp/infographic.html /path/to/output.png 3 750
Arguments:
The script automatically finds Playwright in the npx cache or global install.
If the script fails, use this inline approach:
NODE_PATH=$(find ~/.npm/_npx -name "index.mjs" -path "*/playwright/*" -exec dirname {} \; -exec dirname {} \; 2>/dev/null | head -1) \
node -e "
const pw = require('playwright');
(async () => {
const browser = await pw.chromium.launch();
const ctx = await browser.newContext({ viewport: { width: 750, height: 600 }, deviceScaleFactor: 3 });
const page = await ctx.newPage();
await page.goto('file:///tmp/infographic.html', { waitUntil: 'networkidle' });
await page.locator('body').screenshot({ path: 'OUTPUT.png', type: 'png' });
await browser.close();
})();
"
Never use npx playwright screenshot CLI — it doesn't support deviceScaleFactor and produces blurry 1x images.
Telegram delivery (lossless):
OpenClaw's message send routes .png files through Telegram's sendPhoto API, which compresses images to max 2048px on the longest side. To deliver the original high-res image, use sendDocument directly:
bash {baseDir}/scripts/send_telegram.sh /path/to/output.png "Caption text"
Or with the message tool if the platform doesn't compress (Discord, etc.), just send normally.
Other platforms: Most platforms preserve document uploads. Use the message tool with filePath for non-Telegram delivery.
npx playwright install chromium)curl + bot token in ~/.openclaw/openclaw.json共 1 个版本