After line with canvas.toDataURL()
I get an error with
Failed to execute 'toDataURL' on 'HTMLCanvasElement': tainted canvas may no be exported
Tried to search solution at my own, with cross origin, but this didn't help me. Is there any possibility to download image created on canvas? I saw examples with toDataURL()
, but those unfortunately don't work for me. I will consider other solutions.
_handleSaveButton(){
var canvas = document.getElementById('memesCanvas');
console.log(canvas);
var canvasimage=document.createElement("img");
canvasimage.setAttribute('crossOrigin','anonymous');
canvasimage = canvas.toDataURL('image/png');
canvasimage.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
alert(canvasimage);
}
<ReactButton onClick={() => this._handleSaveButton()} styleName={'generate-meme'} name='generate meme'/>