2015-11-29 19:58:58 +00:00
|
|
|
import {
|
|
|
|
NativeModules,
|
|
|
|
} from 'react-native';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
createResizedImage: (path, width, height, format, quality) => {
|
|
|
|
if (format !== 'JPEG') {
|
|
|
|
throw new Error('Only JPEG format is supported by createResizedImage');
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2016-03-13 15:49:17 +00:00
|
|
|
NativeModules.ImageResizer.createResizedImage(path, width, height, quality, (err, resizedPath) => {
|
2015-11-29 19:58:58 +00:00
|
|
|
if (err) {
|
|
|
|
return reject(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(resizedPath);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|