Convert SVG files to PNG using a headless browser for pixel-perfect rendering.
Most SVG-to-PNG tools use librsvg or similar, which often renders SVGs differently than browsers do. This tool uses a real Chromium browser (via Astral) to ensure the output matches what you see in your browser.
deno add jsr:@pumpn/svg-to-pngdeno task svg-to-png -i input.svg -o output.pngWith resizing:
deno task svg-to-png -i input.svg -o output.png --width 512
deno task svg-to-png -i input.svg -o output.png --height 256
deno task svg-to-png -i input.svg -o output.png --width 512 --height 512import svgToPng from "@pumpn/svg-to-png";
await svgToPng("input.svg", "output.png");
// With options
await svgToPng("input.svg", "output.png", {
resizeWidth: 512,
resizeHeight: 512,
compress: true // uses oxipng (default: true)
});