我在Android的Ionic应用程序中使用cordova-plugin-camera v1.2拍照。它会将裁剪后的图像和原始照片与其时间戳保存到应用程序缓存中。但通常原始照片的时间戳大于裁剪的和插件返回原始照片的文件uri而不是裁剪的。你可以在下面找到插件的用法。
用法是:
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();
});
})
}