ImageSourceModule method toBase64String not working (both iOS and Android)
See original GitHub issueOn line 140 of image-source-android.js this.android.compress(targetFormat, quality, base64Stream);
I’m getting this error this.android.compress is not a function
. I’m using the nativescript-camera to take a picture and then save it to base64 string. Also, the image is saving to my photos even when I set saveToGallery: false
.
Here my code:
cameraModule.takePicture({
width: 1280, height: 720, keepAspectRatio: false, saveToGallery: false
}).then(function (imageAsset) {
console.log("Result is an image asset instance");
viewModel.set("BoardingPassSource", imageAsset);
var image = ImageSourceModule.fromNativeSource(imageAsset);
var base64 = image.toBase64String("jpeg");
// var image = new imageModule.Image();
// image.imageSource = imageAsset;
// image.toBase64String("jpeg");
viewModel.set("base64String", base64);
}).catch(function (err) {
console.log("Error -> " + err.message);
});
package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.****",
"tns-android": {
"version": "2.5.0"
}
},
"dependencies": {
"nativescript-background-http": "^2.4.2",
"nativescript-barcodescanner": "^2.3.3",
"nativescript-camera": "0.0.8",
"nativescript-drawingpad": "^1.1.2",
"nativescript-drop-down": "^1.5.1",
"nativescript-loading-indicator": "^2.2.2",
"nativescript-telerik-ui": "^1.5.1",
"nativescript-theme-core": "^1.0.2",
"nativescript-timedatepicker": "^1.1.0",
"tns-core-modules": "^2.5.0"
},
"devDependencies": {
"babel-traverse": "6.21.0",
"babel-types": "6.21.0",
"babylon": "6.14.1",
"lazy": "1.0.11"
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:25 (9 by maintainers)
Top Results From Across the Web
ImageSourceModule method toBase64String not working ...
ImageSourceModule method toBase64String not working (both iOS and ... I'm getting this error this.android.compress is not a function .
Read more >[Resolve]-trying to store image as base64 and using it
When I run this.image = "~/assets/images/account/camera.png" (just a placeholder, even calling a method does not work too) for example it catches an error....
Read more >Unable to decode base64string to uiimage in iOS swift but ...
I have this code to convert UIImage to base64EncodedString and from base64EncodedString back to UIImage on both iOS and Android app. The problem...
Read more >Nativescript 6.2 Convert Base64 Image String To Imagesource
ImageSourceModule method toBase64String not working both iOS and Android #3605 to take a picture and then save it to base64 string.
Read more >ImageSource module - NativeScript Docs
Load image using resource name ... This is similar to loading Bitmap from R.drawable.logo on Android or calling [UIImage imageNamed@"logo"] on iOS. The...
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 Free
Top 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
I found another alternative!
now I want to find a way to compress the ImageAsset or the ImageSource. Any suggestions? @pap5508 @NickIliev
I used the
nativescript-camera
andnativescript-imagepicker
to take a picture, save it and convert it to base 64. I hope it helps. If anyone has another workaround please let me know.