Quantcast
Channel: Convert SVG to image (JPEG, PNG, etc.) in the browser - Stack Overflow
Viewing all articles
Browse latest Browse all 17

Answer by coop for Convert SVG to image (JPEG, PNG, etc.) in the browser

$
0
0

jbeard4 solution worked beautifully.

I'm using Raphael SketchPad to create an SVG. Link to the files in step 1.

For a Save button (id of svg is "editor", id of canvas is "canvas"):

$("#editor_save").click(function() {// the canvg call that takes the svg xml and converts it to a canvascanvg('canvas', $("#editor").html());// the canvas calls to output a pngvar canvas = document.getElementById("canvas");var img = canvas.toDataURL("image/png");// do what you want with the base64, write to screen, post to server, etc...});

Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>