selected.getImage is not a function
See original GitHub issueI’m making an app where some data are stored in a SQL database. But in order to store images and videos I need to get the file uri first. I tried everything I could but nothing worked.
This is how my JS file looks like:
var imagepicker = require("nativescript-imagepicker");
var permissions = require( "nativescript-permissions" );
var ImageSourceModule = require("image-source");
function openImage() {
var context = imagepicker.create({ mode: "single" }); // use "multiple" for multiple selection
context
.authorize()
.then(function() {
return context.present();
})
.then(function(selection) {
selection.forEach(function(selected) {
selected.getImage().then((source) => {
console.log(selected.fileUri);
});
});
}).catch(function (e) {
alert(e);// process error
});
}
exports.openImage = openImage;
I can select images without a problem but then I get this error “selected.getImage is not a function”.
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (2 by maintainers)
Top Results From Across the Web
Nativescript imagepicker .getImage() is not a function error
I have been trying to implement the answer to this question but keep getting the error "selected.getImage is not a function".
Read more >Uncaught TypeError: t.getLayerStatesArray is not a function ...
An Authentication object was not found in the SecurityContext. This request requires HTTP authentication. – csandreas1. Mar 13, 2019 at 12:30.
Read more >GetImage Function - CSPro Help
The function returns a string containing the image filename, or a blank string if there is no value set image for the provided...
Read more >CanvasRenderingContext2D.getImageData() - Web APIs | MDN
This method is not affected by the canvas's transformation matrix. ... The optional colorSpace setting allows you to get image data in the ......
Read more >getimagesize - Manual
This function does not require the GD image library. ... Note: getimage size doesn't attempt to validate image file formats
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 tested this using the latest (6.0.1) version of the image picker plugin. For Android, getting the image path is very easy. Assuming
selectionis the array of image assets returned from the image picker:For iOS, it is a bit more tricky as the native PHAsset object does not have a property containing the path:
You need to add the
tns-platform-declarationsdependency to your app. It contains the definitions for all native objects like NSData and UIImageOrientation.