Error:Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded

I got my problem. It should be helpful for another user for save the image and compress the image using javascript(AnguarJs).

I am flowing this link to compress the image Github

https://github.com/oukan/angular-image-compress

var imageData = $scope.image1.compressed.dataURL.toString();
var byteCharacters = atob(imageData.replace(/^data:image\/(png|jpeg|jpg);base64,/, ''));
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
  byteNumbers[i] = byteCharacters.charCodeAt(i);
}

var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([ byteArray ], {
   type : undefined
});

Tags:

Html

Angularjs