Created
September 16, 2019 18:44
-
-
Save klcodanr/2fbfc9b1ea369ad42b62cbe0aeb6ea09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function svg2img(){ | |
var svg = document.querySelector('svg'); | |
var xml = new XMLSerializer().serializeToString(svg); | |
var svg64 = btoa(xml); | |
var b64start = 'data:image/svg+xml;base64,'; | |
var image64 = b64start + svg64; | |
return image64; | |
}; | |
var img = document.createElement('img'); | |
img.src = svg2img(); | |
document.body.appendChild(img); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment