NgCordova camera - Take square images like instagram (iOS)?

I have an application for Ionic that shoots with the ngCordova camera plugin, but I want the images to be square. I also need, if possible, an overlay that shows which area will be cropped. Here is the code I'm using:

$ 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

+6
source share
1 answer

I followed Nic Raboy's tutorial and was able to get everything using the following settings: allowEdit, targetWidth and targetHeight.

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

If you need help just let me know
Good luck

JS controller

 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 }); } }); 
+2
source

Source: https://habr.com/ru/post/983756/


All Articles