1 |
|
2 |
|
3 | import { NativeModules } from 'react-native';
|
4 |
|
5 | const { ExponentImageManipulator } = NativeModules;
|
6 |
|
7 | type ImageResult = {|
|
8 | uri: string,
|
9 | width: number,
|
10 | height: number,
|
11 | base64?: string,
|
12 | |};
|
13 |
|
14 | type CropParameters = {
|
15 | originX: number,
|
16 | originY: number,
|
17 | width: number,
|
18 | height: number,
|
19 | };
|
20 |
|
21 | type ImageManipulationOptions = {
|
22 | resize?: { width?: number, height?: number },
|
23 | rotate?: number,
|
24 | flip?: { vertical?: boolean, horizontal?: boolean },
|
25 | crop?: CropParameters,
|
26 | };
|
27 |
|
28 | type SaveOptions = {
|
29 | base64?: boolean,
|
30 | compress?: number,
|
31 | format?: 'jpeg' | 'png',
|
32 | };
|
33 |
|
34 | export async function manipulate(
|
35 | uri: string,
|
36 | actions: ImageManipulationOptions[] = [],
|
37 | saveOptions?: SaveOptions = {}
|
38 | ): Promise<ImageResult> {
|
39 | return ExponentImageManipulator.manipulate(uri, actions, saveOptions);
|
40 | }
|