2015-03-13 24 views
6

我有我的離子應用程序與ngCordova相機插件拍照,但我想圖片是方形的。如果可能的話,我還需要一個疊加層來顯示哪個區域將被裁剪。下面是我使用的代碼:ngCordova相機 - 採取Instagram的方形圖片(iOS)?

$ scope.getPhoto =函數(){

Camera.getPicture().then(function(imageURI) { 
    console.log(imageURI); 
    $scope.lastPhoto = imageURI; 
}, function(err) { 
    console.err(err); 
}, { 
    quality: 75, 
    targetWidth: 320, 
    targetHeight: 320, 
    saveToPhotoAlbum: false 
}); 

};

感謝您的幫助

+0

我也有同樣的問題! – NMO 2015-03-13 16:30:18

回答

2

我跟着尼克Raboy的教程,並設法使用以下設置「allowEdit」,「targetWidth」 &「targetHeight」一切工作。

教程URL - https://blog.nraboy.com/2014/09/use-android-ios-camera-ionic-framework/

如果您需要任何幫助,只是讓我知道,
祝你好運!

控制器JS

cameraApp.controller("cameraApp", function($scope, $cordovaCamera) { 

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

     $cordovaCamera.getPicture(options).then(function(imageData) { 
      $scope.imgURI = "data:image/jpeg;base64," + imageData; 
     }, function(err) { 
      // An error occured. Show a message to the user 
     }); 
    } 

}); 
+0

完美。謝謝 – 2018-01-27 12:45:17