4 ms·
if anyone has a link etc. where I can find more / better info on exporting an SVG as a image. It would be appreciated.
by taivare 10y ago
if anyone has a link etc. where I can find more / better info on exporting an SVG as a image. It would be appreciated.
- thom 10y agohttps://github.com/exupero/saveSvgAsPng https://github.com/exupero/saveSvgAsPng
- ceautery 10y agoA poor man's version is to draw it onto a canvas and save the canvas, e.g.: var svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>'; i = new Image(); var cnv = document.createElement('canvas'); var ctx = cnv.getContext('2d'); i.onload = function() { ctx.drawImage(i, 0, 0); console.log(cnv.toDataURL()); } i.src = 'data:image/svg+xml;base64,'+ btoa(svg);
- thom 10y agoNow copy across all styles, embed all fonts and external images etc etc etc. Nightmare.