$ yarn add react-native-photo-manipulator
(or)
$ npm install react-native-photo-manipulator
From react-native 0.60 autolinking will take care of the link step but don't forget to run pod install
. So you can skip to next section.
For react-native 0.59.x and below. React Native modules that include native Objective-C, Swift, Java, or Kotlin code have to be "linked" so that the compiler knows to include them in the app.
$ react-native link react-native-photo-manipulator
NOTE: If you ever need to uninstall React Native Photo Manipulator, run react-native unlink react-native-photo-manipulator to unlink it.
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-photo-manipulator
and addRNPhotoManipulator.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPhotoManipulator.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.guhungry.rnphotomanipulator.RNPhotoManipulatorPackage;
to the imports at the top of the file - Add
new RNPhotoManipulatorPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':react-native-photo-manipulator'
project(':react-native-photo-manipulator').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-photo-manipulator/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
implementation project(':react-native-photo-manipulator')
import RNPhotoManipulator from 'react-native-photo-manipulator';
const image = "https://github.com/guhungry/react-native-photo-manipulator/raw/master/docs/demo-background.jpg";
const cropRegion = { x: 5, y: 30, size: 400, width: 250 };
const targetSize = { size: 200, width: 150 };
PhotoManipulator.crop(image, cropRegion, targetSize).then(path => {
console.log(`Result image path: ${path}`);
});
Learn more about API