$ npm install react-native-media-manipulator --save
$ react-native link react-native-media-manipulator
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-media-manipulator
and addRNMediaManipulator.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNMediaManipulator.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.davidbjerremose.reactnativemediamanipulator.RNMediaManipulatorPackage;
to the imports at the top of the file - Add
new RNMediaManipulatorPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-media-manipulator' project(':react-native-media-manipulator').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-media-manipulator/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-media-manipulator')
import RNMediaManipulator from 'react-native-media-manipulator';
RNMediaManipulator.mergeImages({
uri: 'https://example.com/image.png',
width: 1000, // height of final image
height: 500 // width of final image
}, [
{
uri: 'http://example.com/otherimage.png', // URI for other image you want merge on top of the background,
width: 200, // width of image
height: 200, // height of image
scale: 1, // scale of image
rotate: '0deg', // rotation of image
x: 20, // x position of image
y: 200 // y position of image
}
]).then(uri => {
// do something with your new image that is stored in tmp
}).catch(error => {
// something went wrong creating the image.
})