I have a problem with my canvas, I'm painting an image in base64 and I want to remove it after painting it on the canvas, when using toDataURL it shows me a base64 that corresponds to a black image. I leave my current code thanks.
var imgData = e.target.result;
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var image = new Image();
image.onload = function() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(image, canvas.width / 2 - image.width / 2,canvas.height / 2 - image.height / 2);
};
image.src = imgData;
var imageURL = canvas.toDataURL("image/jpeg");
this.imageData = imageURL;