【问题标题】:ngCordova Camera - Take square pictures like instagram (iOS)?ngCordova Camera - 像 instagram (iOS) 一样拍摄方形照片?
【发布时间】:2015-05-16 04:44:05
【问题描述】:

我的 Ionic 应用程序使用 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
});

};

感谢您的帮助

【问题讨论】:

  • 我也有同样的问题!

标签: ios ionic-framework ionic ngcordova


【解决方案1】:

我遵循 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
        });
    }

});

【讨论】:

  • 完美。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多