I am trying to load an image from a url and convert it to a base64 string.
All i get is a string but when I use it as the html source of the image, the images is always blank.
What am I doing wrong?
function getBase64Image(imgUrl) {
var image = new Image();
var canvas = document.createElement("canvas");
var context = canvas.getContext('2d');
image.src = imgUrl;
context.drawImage(image,0,0);
return canvas.toDataURL();
}
The function returns the string.
Thank you.