I am taking pictures with cordova-plugin-camera v1.2 in my Ionic application for Android. It saves the cropped image and the original photo to the app cache with their timestamps. But generally original photo’s timestamp bigger than the cropped one and plugin returns the original photo’s file uri instead of cropped one. You can find the usage of the plugin below.
The usage is:
function optionsForType(type) {
var source;
switch (type) {
case 0:
source = Camera.PictureSourceType.CAMERA;
break;
case 1:
source = Camera.PictureSourceType.PHOTOLIBRARY;
break;
}
return {
destinationType: Camera.DestinationType.FILE_URI,
quality: 75,
sourceType: source,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation: true,
targetHeight: 500,
targetWidth: 500
};
}
function saveMedia(type) {
return $q(function(resolve, reject) {
var options = optionsForType(type);
$cordovaCamera.getPicture(options).then(function(imageUrl) {
if(ionic.Platform.isAndroid()){
window.resolveLocalFileSystemURL(imageUrl, function(fileEntry){
imageUrl = fileEntry.nativeURL;
});
}
FileService.storeImage(imageUrl);
resolve();
});
})
}