Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG to ImageFormat #47

Open
timonson opened this issue Jan 23, 2023 · 2 comments
Open

SVG to ImageFormat #47

timonson opened this issue Jan 23, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@timonson
Copy link

Is it possible with this library to convert SVGs to PNGs?

Thank you!

@DjDeveloperr
Copy link
Owner

Not possible right now, but something that is definitely wanted.

@DjDeveloperr DjDeveloperr added enhancement New feature or request help wanted Extra attention is needed labels Jan 23, 2023
@jdgamble555
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants