离子图像作物,同时从图库中选择图像

问题描述:

我已经使用cordova plugin camera在离子v1和角度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 
        }); 
       } 

是否有图像在选择图片库图片.. 为我的项目我也使用cordova plugin crop这个时间裁剪任何解决方案.. 有像选项,

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

}) 
.catch(function fail (err) { 

}) 

但它不工作,它只是为Android我猜..

任何人知道这个请帮忙吗?

如果你想在iOS中访问这个,那么你需要在targetWidth,targetHeight中提供高分辨率图片。 尝试增加:

targetWidth:2000,targetHeight:2000

它在iOS和Android为我工作。

尝试这种解决方案用于其工作$ cordovaCamera

navigator.camera.getPicture(gotPhoto, onError, { 
          quality: 90, 
          destinationType: navigator.camera.DestinationType.FILE_URI, 
          sourceType: navigator.camera.PictureSourceType.CAMERA, 
          allowEdit: true, // here it allow to edit pic. 
          encodingType: Camera.EncodingType.JPEG, 
          mediaType: Camera.MediaType.PICTURE, 
          targetWidth: 200, //what widht you want after capaturing 
          targetHeight: 200 
         }); 

尝试这... ...因为我have't测试它画廊的画廊,但它上面种植适用于相机。

navigator.camera.getPicture(gotPhoto, 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 
         }); 

有关详细信息,请参阅PLZ这link

+0

我已经尝试过这种解决方案并获得相机打开,而不是进行裁剪画廊图像。 –

+0

@Hartarthipanchal尝试一下我没有为画廊进行测试,但它适用于相机裁剪。 – Pritish

+0

我想你没有得到我的问题。我已经明确提到,我想从图片库中选择图像的裁剪。 –