svg2png wasm
SVG to PNG converter JS library made with WASM + resvg.
Usage
Installation
Node.js
npm install svg2png-wasm
Browser
🚧 WIP
Example
Node.js
import { svg2png } from 'svg2png-wasm';
import { readFileSync, writeFileSync } from 'fs';
const png = await svg2png(
'<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> ... </svg>',
{
scale: 2,
width: 400,
height: 400,
fonts: [
readFileSync('./Roboto.otf'),
],
}
);
writeFileSync('./output.png', png);
Browser
🚧 WIP
API
function svg2png(
svg: string,
options?: {
scale?: number;
width?: number;
height?: number;
fonts?: Uint8Array[];
}
): Promise<Uint8Array>