react-native-image-editor
Image Editor Native module for React Native. This module was extracted from React-Native core in the "Lean Core" process.
Getting started
Install
yarn add @react-native-community/image-editor
or
npm install @react-native-community/image-editor --save
Link
react-native link @react-native-community/image-editor
Api reference
static cropImage(uri, cropData, success, failure)
Crop the image specified by the URI param. If URI points to a remote image, it will be downloaded automatically. If the image cannot be loaded/downloaded, the failure callback will be called.
If the cropping process is successful, the resultant cropped image will be stored in the ImageStore, and the URI returned in the success callback will point to the image in the store. Remember to delete the cropped image from the ImageStore when you are done with it.
cropData
offset
- The top-left corner of the cropped image, specified in the original image's coordinate spacesize
- Size (dimensions) of the cropped imagedisplaySize
(optional) - Size to which you want to scale the cropped imageresizeMode
(optional) - Resizing mode to use when scaling the image
cropData = {
offset: {x: number, y: number},
size: {width: number, height: number},
displaySize: {width: number, height: number},
resizeMode: 'contain/cover/stretch',
};
For more advanced usage check our example app.