@oguzhnatly/react-native-image-manipulator 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +44 -40
- package/index.d.ts +35 -0
- package/{index.js → index.ts} +0 -0
- package/package.json +3 -2
- package/react-native-image-manipulator.podspec +1 -1
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
## Getting started
|
|
2
|
+
|
|
3
|
+
`$ npm install @oguzhnatly/react-native-image-manipulator --save`
|
|
4
|
+
### OR
|
|
5
|
+
`$ yarn add @oguzhnatly/react-native-image-manipulator`
|
|
6
|
+
|
|
7
|
+
### Pod installation
|
|
8
|
+
|
|
9
|
+
`$ cd ios && pod install`
|
|
10
|
+
|
|
11
|
+
### Mostly automatic installation
|
|
12
|
+
|
|
13
|
+
`$ react-native link @oguzhnatly/react-native-image-manipulator`
|
|
14
|
+
|
|
15
|
+
### Manual installation
|
|
16
|
+
|
|
17
|
+
#### iOS
|
|
18
|
+
|
|
19
|
+
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
|
20
|
+
2. Go to `node_modules` ➜ `@oguzhnatly` ➜ `react-native-image-manipulator` and add `RNImageManipulator.xcodeproj`
|
|
21
|
+
3. In XCode, in the project navigator, select your project. Add `libRNImageManipulator.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
|
22
|
+
4. Run your project (`Cmd+R`)<
|
|
23
|
+
|
|
24
|
+
#### Android
|
|
25
|
+
|
|
26
|
+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
|
27
|
+
|
|
28
|
+
- Add `import com.reactnativeimagemanipulator.RNImageManipulatorPackage;` to the imports at the top of the file
|
|
29
|
+
- Add `new RNImageManipulatorPackage()` to the list returned by the `getPackages()` method
|
|
30
|
+
|
|
31
|
+
2. Append the following lines to `android/settings.gradle`:
|
|
32
|
+
```
|
|
33
|
+
include ':react-native-image-manipulator'
|
|
34
|
+
project(':react-native-image-manipulator').projectDir = new File(rootProject.projectDir, '../node_modules/@oguzhnatly/react-native-image-manipulator/android')
|
|
35
|
+
```
|
|
36
|
+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
|
37
|
+
```
|
|
38
|
+
compile project(':react-native-image-manipulator')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `RNImageManipulator.manipulate(uri, actions, saveOptions)`
|
|
2
42
|
|
|
3
43
|
Manipulate the image provided via `uri`. Available modifications are rotating, flipping (mirroring), resizing and cropping. Each invocation results in a new file. With one invocation you can provide a set of actions to perform over the image. Overwriting the source file would not have an effect in displaying the result as images are cached.
|
|
4
44
|
|
|
@@ -30,7 +70,7 @@ This will first rotate the image 90 degrees clockwise, then flip the rotated ima
|
|
|
30
70
|
```javascript
|
|
31
71
|
import React from "react";
|
|
32
72
|
import { Button, TouchableOpacity, Text, View, Image } from "react-native";
|
|
33
|
-
import
|
|
73
|
+
import RNImageManipulator from "@oguzhnatly/react-native-image-manipulator";
|
|
34
74
|
|
|
35
75
|
import Colors from "../constants/Colors";
|
|
36
76
|
|
|
@@ -63,7 +103,7 @@ export default class ImageManipulatorSample extends React.Component {
|
|
|
63
103
|
}
|
|
64
104
|
|
|
65
105
|
_rotate90andFlip = async () => {
|
|
66
|
-
const manipResult = await
|
|
106
|
+
const manipResult = await RNImageManipulator.manipulate(
|
|
67
107
|
this.state.image.localUri || this.state.image.uri,
|
|
68
108
|
[{ rotate: 90 }, { flip: { vertical: true } }],
|
|
69
109
|
{ format: "png" }
|
|
@@ -88,40 +128,4 @@ export default class ImageManipulatorSample extends React.Component {
|
|
|
88
128
|
);
|
|
89
129
|
};
|
|
90
130
|
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Getting started
|
|
94
|
-
|
|
95
|
-
`$ npm install @oguzhnatly/react-native-image-manipulator --save`
|
|
96
|
-
### OR
|
|
97
|
-
`$ yarn add @oguzhnatly/react-native-image-manipulator`
|
|
98
|
-
|
|
99
|
-
### Mostly automatic installation
|
|
100
|
-
|
|
101
|
-
`$ react-native link react-native-image-manipulator`
|
|
102
|
-
|
|
103
|
-
### Manual installation
|
|
104
|
-
|
|
105
|
-
#### iOS
|
|
106
|
-
|
|
107
|
-
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
|
108
|
-
2. Go to `node_modules` ➜ `react-native-image-manipulator` and add `RNImageManipulator.xcodeproj`
|
|
109
|
-
3. In XCode, in the project navigator, select your project. Add `libRNImageManipulator.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
|
110
|
-
4. Run your project (`Cmd+R`)<
|
|
111
|
-
|
|
112
|
-
#### Android
|
|
113
|
-
|
|
114
|
-
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
|
115
|
-
|
|
116
|
-
- Add `import com.reactnativeimagemanipulator.RNImageManipulatorPackage;` to the imports at the top of the file
|
|
117
|
-
- Add `new RNImageManipulatorPackage()` to the list returned by the `getPackages()` method
|
|
118
|
-
|
|
119
|
-
2. Append the following lines to `android/settings.gradle`:
|
|
120
|
-
```
|
|
121
|
-
include ':react-native-image-manipulator'
|
|
122
|
-
project(':react-native-image-manipulator').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-manipulator/android')
|
|
123
|
-
```
|
|
124
|
-
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
|
125
|
-
```
|
|
126
|
-
compile project(':react-native-image-manipulator')
|
|
127
|
-
```
|
|
131
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare module '@oguzhnatly/react-native-image-manipulator' {
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import RNImageManipulator from './index';
|
|
4
|
+
|
|
5
|
+
export type ImageResult = {
|
|
6
|
+
uri: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
base64?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function manipulate(
|
|
13
|
+
uri: string,
|
|
14
|
+
actions: Array<{
|
|
15
|
+
resize?: {width?: number; height?: number};
|
|
16
|
+
rotate?: number;
|
|
17
|
+
flip?: {vertical?: boolean; horizontal?: boolean};
|
|
18
|
+
crop?: {
|
|
19
|
+
originX?: number;
|
|
20
|
+
originY?: number;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
};
|
|
24
|
+
}>,
|
|
25
|
+
saveOptions: {
|
|
26
|
+
compress?: number;
|
|
27
|
+
format?: 'jpeg' | 'png';
|
|
28
|
+
base64?: boolean;
|
|
29
|
+
},
|
|
30
|
+
callback: (uri: string) => void,
|
|
31
|
+
): Promise<ImageResult>;
|
|
32
|
+
|
|
33
|
+
export default RNImageManipulator;
|
|
34
|
+
}
|
|
35
|
+
|
package/{index.js → index.ts}
RENAMED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oguzhnatly/react-native-image-manipulator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "ImageManipulator for react native without Expo and Unimodules. Based on Expo ImageManipulator",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "oguzhnatly",
|
|
7
7
|
"homepage": "https://github.com/oguzhnatly/react-native-image-manipulator",
|
|
8
|
-
"license": "MIT"
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"typings": "index.d.ts"
|
|
9
10
|
}
|
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name =
|
|
6
|
+
s.name = "react-native-image-manipulator"
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|