Skip to content

Vyoo/react-native-image-cropping

 
 

Repository files navigation

react-native-image-cropping

Simple react-native image cropping library wrapper around TimOliver/TOCropViewController

TOCropViewController

Installation

npm i https://github.com/vyoo/react-native-image-cropping
react-native link react-native-image-cropping

Supported platforms

Supported only on iOS.

Usage

Import module

import ReactNativeImageCropping from 'react-native-image-cropping';

Crop the image

It is using RCTImageLoader so it should be able to crop any image that react knows how to load / display.

Without aspect ratio restriction:

const originalImage = require('CrazyFlowers.jpg');

ReactNativeImageCropping.cropImageWithUrl(originalImage.uri).then(
	image => {
		//Image is saved in NSTemporaryDirectory!
		//image = {uri, width, height}
	},
	err => console.log(err)
);

Lock to specific aspect ratio:

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)
);

About

Wrapper around 3rd party library for image cropping on iOS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 89.7%
  • Ruby 8.3%
  • JavaScript 2.0%