How to get selected image information with camera plugin


#1

Hi,

I am using cordova camera plugin to choose image from user, user can opt for either camera or from photo library options so i am able to get the selected image in base64 string, is there any options or any way to get the details of selected image information such as size(when we calculate the size with base 64 string length we are not getting original size), image format(as we are getting base64 string we don’t whether user selected gif/JPEG.
I need to implement the functionality to restrict the user uploading images with size and image format. If there is a any other options other than camera plugin please suggest.

Thank you.


#2
function takePhoto() {
    navigator.camera.getPicture(gotPhoto, onError, { quality: 50,
        destinationType: navigator.camera.DestinationType.FILE_URI,
        sourceType: navigator.camera.PictureSourceType.CAMERA });
}

function gotPhoto(imageUri) {
    window.resolveLocalFileSystemURI(imageUri, function(fileEntry) {
        fileEntry.file(function(fileObj) {
            console.log("Size = " + fileObj.size);
        });
    });
}

http://stackoverflow.com/questions/11993043/cordova-phonegap-photo-file-size

watch the accepted answer at SO.