我需要打开图库以在我的Android应用中选择图片。这是我的代码,可以正常工作。
但是通过使用PHOTOLIBRARY,它将打开设备照片库中的图像,而使用SAVEDPHOTOALBUM将仅从设备的“相机胶卷”相册中选择图像-如我在这里可以阅读的https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/
我想打开我的应用程序专用文件夹而不是图库文件夹(例如:我创建一个名为“ MYAPPIMAGES”的文件夹,其中包含我应用程序中的图像,并且我只想显示“ MYAPPIMAGES”文件夹中的图像,而不是画廊中的所有图像)。我该如何实现这种行为?有机会这样做吗?提前致谢。
var picOptions = {
destinationType: navigator.camera.DestinationType.FILE_URI,
quality: 80,
targetWidth: 800,
targetHeight: 800,
maximumImagesCount: 5,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
};
$cordovaImagePicker.getPictures(picOptions).then(function (imageURI) {
for (var i = 0; i < imageURI.length; i++) {
var str = imageURI[i];
var n = str.lastIndexOf('/');
var splitStr = str.substring(n+1);
var dir = str.substring(0,n+1);
console.log(imageURI[i]+' '+splitStr+' '+dir);
convert64(imageURI[i], splitStr, dir);
}
最佳答案
该选项中唯一允许的值为:
Camera.PictureSourceType:枚举
定义Camera.getPicture调用的输出格式。注意:在iOS上,由于特定于实现,将PictureSourceType.PHOTOLIBRARY或PictureSourceType.SAVEDPHOTOALBUM与DestinationType.NATIVE_URI一起传递将禁用任何图像修改(调整大小,更改质量,裁剪等)。
种类:Camera的静态枚举属性
物产
Name Type Default Description
PHOTOLIBRARY number 0 Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android)
CAMERA number 1 Take picture from camera
SAVEDPHOTOALBUM number 2 Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android)
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/#module_camera.CameraOptions