I am creating a Snap.svg app where users can basically add blocks and manipulate them then save it to a png. The blocks are all drawn in inches. I have code that calculates the device PPI and that is used to draw the blocks, it gets calculated to 96 PPI. This all works fine except that when I save the SVG to a PNG it is saved with 72 PPI so then the save PNG is larger than what it should be.
I am using this JavaScript Library to save the SVG as a PNG.
So my question is how do I get around this issue?
I am using this library: https://github.com/sampumon/SVG.toDataURL it works really well.
This is the code I ended up with that works for me.
// Get the SVG element
var svg = document.getElementById("design-1");
svg.toDataURL("image/png", {
callback : function(data) {
// Convert image to 'octet-stream' (Just a download, really)
var image = data.replace("image/png", "image/octet-stream");
window.location.href = image;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With