I wish to create a simple function in angularJS so I can read image from URL. Simply I put image URL and it convert image of that URL to base64 and saves to DB as well it shows to that Image Canvas. I wish to read image of all type irrespective of only PNG.
I have tried few logics, from Google I found code where it takes dimensions of canvas first..
$scope.convertBase64 = function () {
            console.log("Firing Function");
            var canvas = $scope.imageURL;
            canvas.width =  $scope.imageURL.width;
            canvas.height =  $scope.imageURL.height;
            var ctx = canvas.getContext("2d");
            ctx.drawImage($scope.imageURL, 0, 0);
            var dataURL = canvas.toDataURL("image/png");
            $scope.imageURLBase =  dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
            return $scope.imageURLBase;
        };
At same moment I wish to save image's base64 content. How to render using that base64 content anytime irrespective of canvas size using ng-source or else.
 
    