PNG renderer for Shumoku. Rasterizes the SVG @shumoku/renderer draws with @resvg/resvg-js.
Node.js only — depends on the native
@resvg/resvg-jsbinding, so it does not run in the browser.
Install
npm install @shumoku/renderer-png @shumoku/core
Quick start
import { writeFileSync } from 'node:fs'
import { readNetworkModel } from '@shumoku/core'
import { renderNetworkPng } from '@shumoku/renderer-png'
const png = await renderNetworkPng(readNetworkModel(yaml), { scale: 2 }) // → Buffer
writeFileSync('diagram.png', png)
API
| Function | Description |
|---|---|
renderNetworkPng(model, options?) | async → Buffer. Draws the model and rasterizes the SVG |
renderGraphToPng(graph, options?) | async → Buffer. Same, for a NetworkGraph |
renderSvgToPng(svg, options?) | async → Buffer. Rasterizes an SVG string already drawn |
Options: scale (default 2), theme, loadSystemFonts, and iconTimeout. If theme is omitted the model’s own theme is used, else light. External CDN icons are automatically embedded as base64 before rasterizing.
License
AGPL-3.0-only. For commercial licensing, contact contact@shumoku.dev.