@shumoku/renderer-png
v0.2.25
Published
PNG renderer for Shumoku network diagrams
Readme
@shumoku/renderer-png
PNG renderer for Shumoku. Renders the @shumoku/renderer-svg output to a raster image 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/coreQuick start
import { writeFileSync } from 'node:fs'
import { YamlParser } from '@shumoku/core'
import { renderGraphToPng } from '@shumoku/renderer-png'
const { graph } = new YamlParser().parse(yaml)
const png = await renderGraphToPng(graph, { scale: 2 }) // → Buffer
writeFileSync('diagram.png', png)API
| Function | Description |
|----------|-------------|
| renderGraphToPng(graph, options?) | async → Buffer. Convenience: prepareRender + renderPng |
| renderPng(prepared, options?) | async → Buffer. Renders an existing PreparedRender |
PNGRenderOptions has a single field, scale (default 2), the output resolution multiplier. External CDN icons are automatically embedded as base64 before rasterizing.
License
AGPL-3.0-only. For commercial licensing, contact [email protected].
