Cordova Crop Image Plugin
Crop Image after clicking using camera or selecting image.
It crops the images in square shape.
This cordova project uses two plugins:
-
Cordova Camera Plugin — https://github.com/apache/cordova-plugin-camera
-
Cordova Crop Image Plugin — https://github.com/jeduan/cordova-plugin-crop
The Camera plugin is combined with the Crop Image Plugin by putting the Cop Image Plugin Code within the success callback of Camera Plugin Code.
/*Camera Plugin Code*/
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI
});
function onSuccess(imageData) {
console.log(imageData);
/*Crop Image Plugin Code*/
plugins.crop(function success (data) {
console.log(data);
var image = document.getElementById('myImage');
image.src = data;
},
function fail () {
}, imageData, {quality:100});
}
function onFail(message) {
alert('Failed because: ' + message);
}