1 var canvas = document.getElementById("mcanvas");
2 image = canvas.toDataURL("image/png", 1.0).replace("image/png", "image/octet-stream");
3 var link = document.createElement('a');
4 link.download = "my-image.png";
5 link.href = image;
6 link.click();