mirror of
https://github.com/status-im/react-native-image-resizer.git
synced 2025-01-11 23:24:30 +00:00
22 lines
600 B
JavaScript
22 lines
600 B
JavaScript
import {
|
|
NativeModules,
|
|
} from 'react-native';
|
|
|
|
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');
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
NativeModules.ImageResizer.createResizedImage(path, width, height, format, quality, rotation, outputPath, (err, resizedPath) => {
|
|
if (err) {
|
|
return reject(err);
|
|
}
|
|
|
|
resolve(resizedPath);
|
|
});
|
|
});
|
|
},
|
|
};
|