Skip to content

Commit 54dce2a

Browse files
committed
refactor: expose only index.js file
Remove the old school index.ios.js and index.android.js which could lead to some bad Developer Experience
1 parent 363fdcc commit 54dce2a

File tree

5 files changed

+70
-54
lines changed

5 files changed

+70
-54
lines changed

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ PODS:
235235
- React-jsinspector (0.62.0)
236236
- react-native-cameraroll (1.5.2):
237237
- React
238-
- react-native-image-resizer (1.2.0):
238+
- react-native-image-resizer (1.2.2):
239239
- React
240240
- React-RCTActionSheet (0.62.0):
241241
- React-Core/RCTActionSheetHeaders (= 0.62.0)
@@ -435,7 +435,7 @@ SPEC CHECKSUMS:
435435
React-jsiexecutor: 8bf0b2707f05865113415088c398a7f98c0cf546
436436
React-jsinspector: 8e5913c4c6c54f0d3f9c9fc630c465a89cded65d
437437
react-native-cameraroll: 4360c9faab50dc6844f56d222c2d0c7ef5f1fe92
438-
react-native-image-resizer: efae8dd718cbd47755df95aa45ad859e701ad7d8
438+
react-native-image-resizer: e794dc2dbd0db0a1062ac5fa425d5df04c1970ca
439439
React-RCTActionSheet: 674afbc8b9c76e0a83520e0a51da29a70802c03f
440440
React-RCTAnimation: f5f24330d09ee677fb49e0782f8321868f4df431
441441
React-RCTBlob: b773ce6138ab0d172ebd8a455fd4efd200a92549

index.android.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

index.ios.js

Lines changed: 0 additions & 29 deletions
This file was deleted.

index.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { NativeModules, Platform } from 'react-native';
2+
3+
const ImageResizerAndroid = NativeModules.ImageResizerAndroid;
4+
5+
let exportObject = {};
6+
7+
if (Platform.OS === 'android') {
8+
exportObject = {
9+
createResizedImage: (
10+
imagePath,
11+
newWidth,
12+
newHeight,
13+
compressFormat,
14+
quality,
15+
rotation = 0,
16+
outputPath,
17+
keepMeta = false
18+
) => {
19+
return new Promise((resolve, reject) => {
20+
ImageResizerAndroid.createResizedImage(
21+
imagePath,
22+
newWidth,
23+
newHeight,
24+
compressFormat,
25+
quality,
26+
rotation,
27+
outputPath,
28+
keepMeta,
29+
resolve,
30+
reject
31+
);
32+
});
33+
},
34+
};
35+
} else {
36+
exportObject = {
37+
createResizedImage: (path, width, height, format, quality, rotation = 0, outputPath, keepMeta = false) => {
38+
if (format !== 'JPEG' && format !== 'PNG') {
39+
throw new Error('Only JPEG and PNG format are supported by createResizedImage');
40+
}
41+
42+
return new Promise((resolve, reject) => {
43+
NativeModules.ImageResizer.createResizedImage(
44+
path,
45+
width,
46+
height,
47+
format,
48+
quality,
49+
rotation,
50+
outputPath,
51+
keepMeta,
52+
(err, response) => {
53+
if (err) {
54+
return reject(err);
55+
}
56+
57+
resolve(response);
58+
}
59+
);
60+
});
61+
},
62+
};
63+
}
64+
65+
export default exportObject;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "react-native-image-resizer",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Rescale local images with React Native",
5+
"main": "./index.js",
6+
"types": "./index.d.ts",
57
"repository": {
68
"type": "git",
79
"url": "git+https://github.com/bamlab/react-native-image-resizer.git"

0 commit comments

Comments
 (0)