Crop an image in a Cordova app
$ cordova plugin add --save cordova-plugin-crop
function onSuccess (croppedImageUrl) {}
function onFail (errorMessage) {}
var options = {
quality: 1
};
// Crops with a square ratio
plugins.crop.crop(onSuccess, onFail, '/path/to/image', options)
// Crops with a fixed ratio of 800x600
plugins.crop.crop_fixed_ratio_800x600(onSuccess, onFail, '/path/to/image', options)
// Crops with the provided orientation (height/width)
options.height = 100;
options.width = 100;
plugins.crop.crop_fixed_ratio(onSuccess, onFail, '/path/to/image', options)
or, if you are running on an environment that supports Promises (Crosswalk, Android >= KitKat, iOS >= 8)
plugins.crop.promise('/path/to/image', options)
.then(function success (newPath) {
})
.catch(function fail (err) {
})
- quality: Number The resulting JPEG quality. default: 100
- height: Number The desired height of the cropped image
- width: Number The desired width of the cropped image
- iOS: PEPhotoCropEditor
- Android: android-crop
MIT © Jeduan Cornejo