react-native-image-tools-wm
A collection of image processing tools for React Native
Getting started
$ npm install react-native-image-tools-wm --save
Automatic installation
$ react-native link react-native-image-tools-wm
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-image-tools-wm
and addRNImageTools.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNImageTools.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)
iOS CocoaPods
- Add
pod 'RNImageTools', :path => '../node_modules/react-native-image-tools-wm'
to yourios/Podfile
- Run
pod install
while inios
directory
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import net.wowmaking.RNImageToolsPackage;
to the imports at the top of the file - Add
new RNImageToolsPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-image-tools-wm' project(':react-native-image-tools-wm').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-tools-wm/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(':react-native-image-tools-wm')
Usage
;
See examples in the API section.
API
mask(image, maskImage)
Parameter(s)
- image: String - path to image
- maskImage: String - path to mask image
- options: Object
- trimTransparency: Boolean
Returns Promise of
- maskedImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools;
transform(image, translateX, translateY, scale, rotate)
Parameter(s)
- image: String - path to image
- translateX: Number
- translateY: Number
- scale: Number
- rotate: Number - in degrees
Returns Promise of
- transformedImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools ;
resize(image, width, height)
Parameter(s)
- image: String - path to image
- width: Number
- height: Number - in degrees
Returns Promise of
- resizedImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools ;
crop(image, x, y, width, height)
Parameter(s)
- image: String - path to image
- x: Number - top offset
- y: Number - left offset
- width: Number
- height: Number
Returns Promise of
- croppedImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools ;
createMaskFromShape(options)
Creates a bitmap with white background and draws a black shape from provided points. It's intended usage is to generate mask images on the fly.
Parameter(s)
- options: Object
- points: Array of points
- point: Object
- x: Number
- y: Number
- point: Object
- width: Number
- height: Number
- inverted: Boolean
- points: Array of points
Returns Promise of
- maskImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools;
merge(images)
Parameter(s)
- images: Array
- uri: String - path to image
Returns Promise of
- mergedImage: Object
- uri: String
- width: Number
- height: Number
RNImageTools;