Simple react-native image cropping library wrapper around TimOliver/TOCropViewController
npm i https://github.com/vyoo/react-native-image-cropping
react-native link react-native-image-croppingSupported only on iOS.
import ReactNativeImageCropping from 'react-native-image-cropping';It is using RCTImageLoader so it should be able to crop any image that react knows how to load / display.
const originalImage = require('CrazyFlowers.jpg');
ReactNativeImageCropping.cropImageWithUrl(originalImage.uri).then(
image => {
//Image is saved in NSTemporaryDirectory!
//image = {uri, width, height}
},
err => console.log(err)
);Available aspect ratios:
AspectRatioOriginal;
AspectRatioSquare;
AspectRatio3x2;
AspectRatio5x4;
AspectRatio4x3;
AspectRatio5x4;
AspectRatio7x5;
AspectRatio16x9;Example:
const aspectRatio = ReactNativeImageCropping.AspectRatioSquare;
ReactNativeImageCropping.cropImageWithUrlAndAspect(imageUrl, aspectRatio).then(
image => {
//Image is saved in NSTemporaryDirectory!
//image = {uri, width, height}
},
err => console.log(err)
);