cordova-plugin-crop-with-ratio
Crop an image in a Cordova app
Install
$ cordova plugin add --save https://github.com/obeza/cordova-plugin-crop-with-ratio
Usage
let options = quality: 75 widthRatio:1 heightRatio:1 targetWidth:600 targetHeight:600; plugins
or, if you are running on an environment that supports Promises (Crosswalk, Android >= KitKat, iOS >= 8)
pluginscrop
API
- quality: Number
The resulting JPEG quality. default: 100
Ionic / Typescript Example Angular 2 Service
This is an example service that uses ionic-native's built in camera and the cordova-plugin-crop to create a cropped version of the image and return the file path.
;;; @ public options: any = allowEdit: true sourceType: CameraPictureSourceTypeSAVEDPHOTOALBUM mediaType: CameraMediaTypeALLMEDIA destinationType: CameraDestinationTypeFILE_URI {} // Return a promise to catch errors while loading image : Promise<any> // Get Image from ionic-native's built in camera plugin return Camera
Libraries used
- iOS: PEPhotoCropEditor
- Android: android-crop
License
MIT © Jeduan Cornejo