Skip to content
Snippets Groups Projects
Select Git revision
  • a5d4ef6b3f060144691d50715e5b1a5363ada638
  • main default protected
2 results

downloadImg.js

Blame
  • downloadImg.js 451 B
    export function downloadImg(name, canvas) {
    	var imageData = canvas.toDataURL();
    
        // create temporary link  
        var tmpLink = document.createElement('a');  
        tmpLink.download = `${name}.png`; // set the name of the download file 
        tmpLink.href = imageData;  
          
        // temporarily add link to body and initiate the download  
        document.body.appendChild( tmpLink );  
        tmpLink.click();  
        document.body.removeChild( tmpLink );
    }