Skip to content

Instantly share code, notes, and snippets.

@jrc03c
Created February 13, 2020 15:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrc03c/040f7b606031d05697a22079e5d9e65b to your computer and use it in GitHub Desktop.
Save jrc03c/040f7b606031d05697a22079e5d9e65b to your computer and use it in GitHub Desktop.
Download the contents of an HTML5 canvas as an image
function downloadCanvasAsImage(canvas, filename){
let a = document.createElement("a")
a.href = canvas.toDataURL()
a.download = filename
a.dispatchEvent(new MouseEvent("click"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment