Shumoku Docs

Search documentation

Shared docs and current release

Loading search…

日本語

libs/@shumoku/renderer-png/README.md

@shumoku/renderer-png

Generate PNG topology diagrams in Node.js.

PNG renderer for Shumoku. Rasterizes canonical static SVG output from @shumoku/renderer with @resvg/resvg-js. Legacy graph/prepared entry points remain compatible with @shumoku/renderer-svg while consumers migrate.

Node.js only — depends on the native @resvg/resvg-js binding, so it does not run in the browser.

Install

npm install @shumoku/renderer-png @shumoku/core

Quick 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

FunctionDescription
renderGraphToPng(graph, options?)asyncBuffer. Canonical graph path: computes ResolvedLayout and renders the shared static SVG
renderPng(prepared, options?)asyncBuffer. Deprecated compatibility API for an existing legacy PreparedRender
png.renderResolved(layout, options?)asyncBuffer. Canonical path for an existing ResolvedLayout; supports theme and scale

PNGRenderOptions supports scale (default 2), theme, loadSystemFonts, and iconTimeout. If theme is omitted, renderGraphToPng honors graph.settings.theme and otherwise uses the light theme. External CDN icons are automatically embedded as base64 before rasterizing.

License

AGPL-3.0-only. For commercial licensing, contact contact@shumoku.dev.