react-native-image-resizer/index.ios.js

29 lines
673 B
JavaScript
Raw Normal View History

2018-06-13 17:34:15 +00:00
import { NativeModules } from 'react-native';
2015-11-29 19:58:58 +00:00
export default {
createResizedImage: (path, width, height, format, quality, rotation = 0, outputPath) => {
if (format !== 'JPEG' && format !== 'PNG') {
throw new Error('Only JPEG and PNG format are supported by createResizedImage');
2015-11-29 19:58:58 +00:00
}
return new Promise((resolve, reject) => {
2018-06-13 17:34:15 +00:00
NativeModules.ImageResizer.createResizedImage(
path,
width,
height,
format,
quality,
rotation,
outputPath,
(err, response) => {
if (err) {
return reject(err);
}
2015-11-29 19:58:58 +00:00
2018-06-13 17:34:15 +00:00
resolve(response);
}
);
2015-11-29 19:58:58 +00:00
});
},
};