我有我的Ionic app使用ngCordova相机插件拍照,但我希望这些照片是方形的。如果可能的话,我还需要一个覆盖图来显示要裁剪的区域。这是我正在使用的代码:
$ 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
});
};
感谢您的帮助
答案 0 :(得分:2)
我按照 Nic Raboy 教程进行操作,并设法使用以下设置让所有内容正常运行' allowEdit',' targetWidth' &安培; ' targetHeight'
教程网址 - 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
});
}
});