Created
January 21, 2020 07:09
-
-
Save andy3520/a802c6c305848fa2c49c4049646c233b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// other type like gif, bmp,... maybe not working because browser not | |
// it may fallback to png | |
function saveImage(canvas, exportType) { | |
window.open(canvas.toDataURL(`image/${exportType}`)); | |
var gh = canvas.toDataURL(exportType); | |
var a = document.createElement('a'); | |
a.href = gh; | |
a.download = `image.${exportType}`; | |
a.click() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment