How to convert img src to encode base64 binary?

I am converting img src to encode base64 bit string. But it is coming with some addition: “data:image/jpeg;base64,iVBORw…”. I don’t want this extra added string. what should I do?

I am using below method.

convertToDataURLviaCanvas(url, outputFormat) {
return new Promise((resolve, reject) => {
let img = new Image();
img.crossOrigin = ‘Anonymous’;
img.onload = () => {
let canvas = document.createElement(‘CANVAS’),
ctx = canvas.getContext(‘2d’),
canvas.height = img.height;
canvas.width = img.width;
ctx.drawImage(img, 0, 0);
dataURL = canvas.toDataURL(outputFormat);
canvas = null;
img.src = url;
calling via this:-
this.convertToDataURLviaCanvas(this.pathForImage(this.lastImage), “image/jpeg”).then(base64 => {

I found another way to convert image in base64 bit which is quite easy.

Just make small change in cameraOption: