skia_canvas
skia_canvas copied to clipboard
SVG to ImageFormat
Is it possible with this library to convert SVGs to PNGs?
Thank you!
Not possible right now, but something that is definitely wanted.
Got it working with rsvg_wasm
:
import { createCanvas, loadImage } from "https://deno.land/x/canvas/mod.ts";
import { render } from "https://deno.land/x/resvg_wasm/mod.ts";
const svgImage = `...`;
const canvas = createCanvas(1600, 900);
const ctx = canvas.getContext('2d');
// render function from svg string here
const data = await render(svgImage);
const img = await loadImage(data);
ctx.drawImage(img, 0, 0);
const buffer = canvas.toBuffer('image/png');
J