react-native-simple-image-cropper
Simple react-native component for image cropping.
Show Case
![]() |
![]() |
---|
Installation
npm i react-native-simple-image-cropper --save
or
yarn add react-native-simple-image-cropper
Installing dependencies
npm i react-native-reanimated react-native-gesture-handler @react-native-community/image-editor --save
or
yarn add react-native-reanimated react-native-gesture-handler @react-native-community/image-editor
Libraries installation details: @react-native-community/image-editor, react-native-gesture-handler, react-native-reanimated.
Usage
;;; const window = Dimensions;const w = windowwidth; const IMAGE = 'https://picsum.photos/id/48/900/500'; const CROP_AREA_WIDTH = w;const CROP_AREA_HEIGHT = w; Component state = cropperParams: {} croppedImage: '' ; { this; }; handlePress = async { const cropperParams = thisstate; const cropSize = width: 200 height: 200 ; const cropAreaSize = width: CROP_AREA_WIDTH height: CROP_AREA_HEIGHT ; try const result = await ImageCropper; this; catch error console; }; { const croppedImage = thisstate; const src = uri: croppedImage ; return <View> <ImageCropper imageUri=IMAGE cropAreaWidth=CROP_AREA_WIDTH cropAreaHeight=CROP_AREA_HEIGHT containerColor="black" areaColor="black" setCropperParams=thissetCropperParams /> <Button onPress=thishandlePress title="Crop Image" color="blue" /> croppedImage ? <Image source=src /> : null </View> ; }
Area overlay
To add a custom overlay, use the areaOverlay
property
<ImageCropper ... areaOverlay=<Image src=>/>
License
MIT