devcodeio / saveSvgAsPng

Save SVGs as PNGs from the browser.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

saveSvgAsPng

To save a PNG, include the script saveSvgAsPng.js in your page, then call the saveSvgAsPng function with an SVG node, a filename, and an optional scaling factor:

saveSvgAsPng(document.getElementById("diagram"), "diagram.png", 3);

If you just want a dataURI for an SVG, you can call svgAsDataUri with an SVG node, a scaling factor, and a callback:

svgAsDataUri(document.getElementById("diagram"), 1, function(uri) {
  ...
});

Compatible with browserify.

About

Save SVGs as PNGs from the browser.

License:MIT License