【问题标题】:cordova camera plugin camera plugin does not show crop option when select image from gallery从图库中选择图像时,科尔多瓦相机插件相机插件不显示裁剪选项
【发布时间】:2018-01-22 06:27:59
【问题描述】:

我正在使用Cordova camera plugin。当我通过相机拍照时,它会显示裁剪选项。但是当我从图库中选择图像时,它不提供裁剪选项。 当我从图库中选择图片时,任何人都可以帮助我进行裁剪选项

var options = {
      quality: 100,
      allowEdit : 1,
      targetWidth: 800,
      targetHeight: 800,
      destinationType: Camera.DestinationType.FILE_URI,
      sourceType: sourceType,
      encodingType: 0,
      saveToPhotoAlbum: false
    };

【问题讨论】:

    标签: cordova ionic-framework cordova-plugins


    【解决方案1】:

    不支持从Cordova camera plugin 的图库中裁剪图像。为此,您必须将 Cordova camera plugincordova-plugin-crop 结合使用,尝试使用此代码而不是您的代码。

    navigator.camera.getPicture(gotPhotoLibrary, onError, {
     quality: 50,
     destinationType: navigator.camera.DestinationType.FILE_URI,
     sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
     allowEdit: true,
     targetWidth: 200, //what widht you want after capaturing
     targetHeight: 200
     });
    return true;
    
    
    
     function gotPhotoLibrary(imageUri) {
                        var options = {
                            quality: 150,
                            widthRatio: 1,
                            heightRatio: 1,
                            targetWidth: 600,
                            targetHeight: 600
                        };
    plugins.crop.promise(imageUri, options)
      .then(function success(newPath) {
        window.resolveLocalFileSystemURI(newPath, function (fileEntry) {
                                fileEntry.file(function (fileObj) {
                                   // your code here
                                });
                            });
                        });
                    }
    
     function onError(err) {
         alertPopup = $ionicPopup.alert({
             title: '',
             template: err
                    });
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 2018-03-28
      相关资源
      最近更新 更多