UNPKG

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