0
votes

I am using the following code for downloading (taking a snapshot) of a canvas:

    var strMime = "image/png";
    var canvas = document.getElementsByTagName('canvas')[0];
    var link = document.createElement("a");
    link.href = canvas.toDataURL(strMime);
    link.download = 'test1.png';
    link.click();

the thing is that it creates the "test1.png" image with a white background (even if i set the canvas style background color to be transparent)

any idea how to generate transparent png files from canvas?

1

1 Answers