2017-06-01 81 views
4

我已經使用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我猜..

任何人知道這個請幫忙嗎?

回答

0

如果你想在iOS中訪問這個,那麼你需要在targetWidth,targetHeight中提供高分辨率圖片。 嘗試增加:

targetWidth:2000,targetHeight:2000

它在iOS和Android爲我工作。

0

嘗試這種解決方案用於其工作$ 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

我想你沒有得到我的問題。我已經明確提到,我想從圖片庫中選擇圖像的裁剪。 –