Convert to base64


#1

Hi! How to convert image to base 64. I have cdvphotolibrary://photo?photoId=2004;/storage/emulated/0/DCIM/Camera/IMG_20171125_192143.jpg


#2
function getBase64Image(img) {
  var canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;
  var ctx = canvas.getContext("2d");
  ctx.drawImage(img, 0, 0);
  var dataURL = canvas.toDataURL("image/png");
  return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}

#3

Thanks!!! :star_struck: