2015-11-29 20:58:58 +01:00
|
|
|
import {
|
|
|
|
NativeModules,
|
|
|
|
} from 'react-native';
|
|
|
|
|
|
|
|
export default {
|
2016-07-01 03:07:42 +10:00
|
|
|
createResizedImage: (path, width, height, format, quality, rotation = 0, outputPath) => {
|
2016-09-12 18:57:49 +01:00
|
|
|
if (format !== 'JPEG' && format !== 'PNG') {
|
|
|
|
throw new Error('Only JPEG and PNG format are supported by createResizedImage');
|
2015-11-29 20:58:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2016-09-12 18:57:49 +01:00
|
|
|
NativeModules.ImageResizer.createResizedImage(path, width, height, format, quality, outputPath, (err, resizedPath) => {
|
2015-11-29 20:58:58 +01:00
|
|
|
if (err) {
|
|
|
|
return reject(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(resizedPath);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|