Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.27 KB

README.md

File metadata and controls

61 lines (43 loc) · 1.27 KB

cordova-plugin-crop

Crop an image in a Cordova app

Install

$ cordova plugin add --save cordova-plugin-crop

Usage

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) {
})

API

  • 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

Libraries used

License

MIT © Jeduan Cornejo