how to convert to base 64 and DATA URI.
See original GitHub issuecontroller $scope.PhotoData = []; $scope.choosePhotos = function () { var options = { maximumImagesCount: 10, quality: 80, targetWidth: 1000, targetHeight: 1000, };
$cordovaImagePicker.getPictures(options).then(function (results) {
for (var i = 0; i < results.length; i++) {
$scope.PhotoData.push(results[i]);
console.log(results[i]);
}
if(!$scope.$$phase) {
$scope.$apply();
}
}, function (err) {
// An error occured. Show a message to the user
});
};
view code ion-slide ng-repeat=“item in PhotoData” img ng-src=“data:image/jpg;base64,{{item}}” style=“max-width: 100%”
Issue Analytics
- State:
- Created 8 years ago
- Comments:5
Top Results From Across the Web
Convert a Data URI to Base64 or 'File Contents' in Power ...
Discover how to convert a Data URI to a base64 string or Power Automate 'File Contents' property using expressions in Microsoft Power ...
Read more >How to convert URL to Base64
Type or paste paste the URL-address · Press the “Encode URL to Base64” button. · Download or copy the result from the “Base64”...
Read more >Data URLs - HTTP - MDN Web Docs - Mozilla
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 ......
Read more >Base64 Image Encoder
Optimize your images and convert them to base64 online. Drag & Drop your files, copy to clipboard with a click and use the...
Read more >How to convert base64 to normal image URL? - Stack Overflow
Your function is correct, but after it you have to use URL.createObjectURL() like follows: function dataURItoBlob(dataURI) { // convert ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use FileReader:
Initially I tried to use
fileReader.readAsDataURL(actualFile);
which give you the base64 data in one shot but it resulted in corrupt images. A workaround was suggested withreadAsBinaryString()
and thenwindow.btoa()
and solved it. See SO question here.yes, this works, but the problem with is it you take for example a compressed jpeg and convert it to an uncompressed png, resulting in a double the size of the file or more.