从图库中选择图像时进行离子图像裁剪

Hit*_*hal 5 angularjs ionic-framework

cordova plugin camera在 ionic v1 和 angular v1 中使用过。当我们从相机拍照时,插件本身提供了裁剪图像的选项......但是从照片库中选择图像没有选项。

              $scope.choosePhoto = function () {
                    var options = {
                    quality: 75,
                    destinationType: Camera.DestinationType.DATA_URL,
                    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
                    allowEdit: true,
                    encodingType: Camera.EncodingType.JPEG,
                    targetWidth: 200,
                    targetHeight: 200,
                    popoverOptions: CameraPopoverOptions,
                    saveToPhotoAlbum: true
                };

             $cordovaCamera.getPicture(options).then(function (imageData) {
                        $scope.imgURI = "data:image/jpeg;base64," + imageData;
                        window.localStorage.setItem('image',($scope.imgURI));
                    }, function (err) {
                        // An error occured. Show a message to the user
                    });
                }
Run Code Online (Sandbox Code Playgroud)

在选择图库图像时是否有任何图像裁剪解决方案..对于我的项目,我也cordova plugin crop用于此..有一个选项,例如,

plugins.crop.promise('/path/to/image', options)
.then(function success (newPath) {

})
.catch(function fail (err) {

})
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我猜它只适用于android..

任何知道这件事的人请帮忙?

San*_*nde 0

如果你想在 iOS 中访问它,那么你需要在 targetWidth、targetHeight 中提供高分辨率图像。尝试添加:

目标宽度:2000,目标高度:2000

它在 iOS 和 Android 上都对我有用。