2015-03-13 14 views
6

Tôi có ứng dụng Ionic chụp ảnh bằng plugin máy ảnh ngCordova, nhưng tôi muốn hình ảnh là hình vuông. Tôi cũng cần một lớp phủ nếu có thể cho thấy khu vực nào sẽ bị cắt. Đây là mã Tôi đang sử dụng:ngCordova Camera - Chụp ảnh vuông như instagram (iOS)?

$ scope.getPhoto = function() {

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

};

Thanks for the help

+0

Tôi có cùng một câu hỏi! – NMO

Trả lời

2

Tôi đi theo hướng dẫn Nic Raboy và quản lý để có được tất cả mọi thứ làm việc sử dụng các cài đặt sau 'allowEdit', 'targetWidth' & 'targetHeight'.

Hướng dẫn URL - https://blog.nraboy.com/2014/09/use-android-ios-camera-ionic-framework/

Nếu bạn cần bất kỳ sự trợ giúp chỉ cho tôi biết,
Chúc may mắn!

khiển 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

Hoàn hảo. Cảm ơn bạn –

Các vấn đề liên quan