forked from IMMC/react-native-compress-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (27 loc) · 892 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
** author: cjp
** time: 2018/1/15
**/
import {NativeModules} from 'react-native';
import PropTypes from 'prop-types';
const optionsTypes = {
maxWidth: PropTypes.number,
maxHeight: PropTypes.number,
quality: PropTypes.number,
urlList: PropTypes.array,
saveImages: PropTypes.bool,
resultBase64: PropTypes.bool
};
const secondOptions = {
urlList: PropTypes.array
};
// const CompressImage = NativeModules.CompressImage;
export default function CompressImages(options) {
if (options.type === 'quality') {
PropTypes.checkPropTypes(secondOptions, options, 'props', 'react-native-compress-images');
return NativeModules.CompressImages.compressQuality(options);
} else {
PropTypes.checkPropTypes(optionsTypes, options, 'prop', 'react-native-compress-images');
return NativeModules.CompressImages.compressSize(options);
}
};