@raquezha/article-media0.2.1
Deterministic local article media rendering and validation tools (PNG, SVG, MP4) for coding agents
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@raquezha/article-media
60fps terminal zoom + typing rendered deterministically from examples/terminal-zoom-typing.html using
article-media video(MP4 version).
Deterministic local media rendering and validation (PNG, SVG, MP4, and GIF) for technical articles, changelogs, and documentation.
Built on playwright-core and your system Chrome with zero external network requests, zero Playwright-cached FFmpeg binaries, and zero --no-sandbox shortcuts.
article-media is completely style-agnostic: any local HTML, CSS, SVG, Canvas, or WebGL scene works, whether it is a brutalist poster, a 3D/shader experiment, a data visualization, or an editorial card.
Why @raquezha/article-media?
When developers or AI agents generate article visuals with ad-hoc scripts, the same bugs keep showing up:
- Silent network and font drift: Diagrams look fine on macOS, then fall back to system fonts on Linux or Safari because weights weren't embedded.
- Half-painted animations:
page.screenshot()fires before CSS transforms or web fonts settle. - Non-repeatable renders: Wall-clock CSS timers produce different frames every run.
- Broken exports: Failed FFmpeg or encoder runs overwrite the previous working file.
@raquezha/article-media turns article visuals into deterministic build artifacts:
| Capability | article-media |
Raw Playwright / FFmpeg | shot-scraper |
|---|---|---|---|
| 2x PNG with SHA-256 repeatability gate | Yes | DIY | No |
| SVG embedded WOFF2 font + URL audit | Yes | No | No |
Clock-driven MP4 & GIF (renderAt(t)) |
Yes | DIY | Real-time only |
macOS AVFoundation + Linux libx264 pipe |
Yes | DIY | No |
| Atomic output (failed run keeps prior file) | Yes | DIY | No |
Bundled AI Agent Skill (SKILL.md) |
Yes | No | No |
Installation & Quick Start
Run directly with npx, or install globally:
# Run without installing
npx @raquezha/article-media --help
# Or install globally
npm install -g @raquezha/article-media
30-Second Example
- Create a local HTML scene with a
#capturecontainer:
<!doctype html>
<html>
<body style="margin:0">
<div id="capture" style="width:800px;height:400px;display:grid;place-items:center;background:#fdfdfc;font-family:sans-serif;">
<h1>Hello, deterministic media</h1>
</div>
</body>
</html>
- Capture a 2x retina PNG (
1600x800) with overflow, font, and SHA-256 repeatability checks:
npx @raquezha/article-media image --scene scene.html --width 800 --height 400 --output card.png
Commands
1. Deterministic 2x PNG (image)
article-media image \
--scene examples/comparison-card.html \
--width 1200 --height 675 \
--output out.png
- Freezes CSS animations, transitions, and text carets.
- Waits for
document.fonts.readyand tworequestAnimationFrameflushes. - Asserts exact
#capturebounds and zero scroll overflow (unless--allow-overflowis passed). - Captures twice and compares SHA-256 hashes before writing
--output.
Optional flags: --scale <n> (default 2), --selector <css> (default #capture), --allow-overflow.
2. SVG Portability Check & Preview (svg)
article-media svg \
--input diagram.svg \
--check \
--preview preview.png
Checks:
- Explicit
viewBox, numericwidth, and numericheighton<svg>. - Zero external
http://orhttps://URLs inhref,src,url(...), or@import. - Every
CaveatorInterweight referenced via XML attributes or inlinestyle="..."has a matchingdata:font/woff2;base64,...@font-facerule. - Optional
--preview <file.png>renders the SVG inside an isolated<img>tag in Chrome so you can inspect the exact output.
3. Clock-Driven MP4 & GIF (video)
Scenes define a pure window.renderAt(seconds) function instead of wall-clock CSS or requestAnimationFrame timers:
<script>
window.renderAt = (seconds) => {
const progress = Math.min(1, seconds / 4);
document.getElementById("box").style.transform = `scale(${1 + 0.25 * progress})`;
};
</script>
Render keyframes first, then encode the full .mp4 or .gif:
# Step 1: Inspect start, middle, and end keyframes (<output>.preview/)
article-media video \
--scene examples/terminal-zoom-typing.html \
--duration 6 --fps 60 --width 1280 --height 720 \
--output demo.mp4 --preview
# Step 2: Encode full 60fps MP4 or 24fps GIF
article-media video \
--scene examples/terminal-zoom-typing.html \
--duration 6 --fps 60 --width 1280 --height 720 \
--output demo.mp4
Backwards compatibility: story-video render ... forwards directly to article-media video ....
4. Batch Manifest (batch)
Keep one media.json manifest alongside an article and regenerate or verify every asset in one command:
article-media batch --manifest media.json
[
{ "kind": "image", "scene": "card.html", "width": 1200, "height": 675, "output": "out/card.png" },
{ "kind": "svg", "input": "flow.svg", "preview": "out/flow-preview.png" },
{ "kind": "video", "scene": "demo.html", "duration": 5.5, "fps": 60, "width": 1280, "height": 720, "output": "out/demo.mp4" }
]
Using With AI Coding Agents
@raquezha/article-media ships a bundled Agent Skill ("pi": { "skills": ["article-media"] }) that teaches agents the 5-step workflow plus video and zoom framing rules:
- Define a one-sentence claim and choose SVG, PNG, or MP4/GIF.
- Author a self-contained local scene (never fake historical product screenshots).
- Run
article-mediawith deterministic checks. - Visually inspect the rendered PNG or
--previewkeyframes before approving (including a peak-zoom frame before full video encodes, readable typing cadence, and measured DOM click targets). - Publish and mirror assets without leaving temp files behind.
To make the skill discoverable in Antigravity across all projects, symlink it into your global skills directory:
mkdir -p ~/.gemini/config/skills
ln -sfn "$(pwd)/article-media" ~/.gemini/config/skills/article-media
Or link it per workspace under .agents/skills/article-media.
Platform Requirements & Determinism
- macOS: Google Chrome installed and Swift / Xcode Command Line Tools (
AVFoundationfor MP4,ImageIOfor GIF). - Linux: System Chrome or Chromium plus
ffmpeg(libx264) andffprobe(MP4 streams viaimage2pipe, GIF usespalettegen/paletteuse). Even--widthand--heightare required foryuv420pH.264. - Browser override: Set
ARTICLE_MEDIA_CHROME(orSTORY_VIDEO_CHROME) to point to a custom Chrome/Chromium executable. - Cross-OS flags: Launches Chrome with
--font-render-hinting=noneand--force-color-profile=srgb(plus--disable-dev-shm-usageon Linux), and locks context tocolorScheme: "light",locale: "en-US",timezoneId: "UTC", andreducedMotion: "reduce".
Examples
- examples/terminal-zoom-typing.html: smooth 60fps camera zoom and character-sliced typing driven purely by
window.renderAt(seconds). - examples/comparison-card.html: 1200x675
#capturetemplate for 2x PNG figures (preview below). - examples/mobile-figma-canvas.html: Figma-style mobile screen canvas with bound token inspector (preview below).
- examples/non-figma-scene.html: non-product scene for render and readability checks.
License
MIT