@teamnhz/rn-ui-toolkit 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,7 @@ import { launchCamera, launchImageLibrary } from "react-native-image-picker";
|
|
|
5
5
|
import ImageCropPicker from "react-native-image-crop-picker";
|
|
6
6
|
import { Image as ImageCompressor, Video as VideoCompressor, } from "react-native-compressor";
|
|
7
7
|
import { Colors, Images, Scale, Typography } from "../../styles";
|
|
8
|
+
import ImageResizer from "react-native-image-resizer";
|
|
8
9
|
// Permissions
|
|
9
10
|
import { cameraPermissions, galleryPermissions, checkMicroPhonePermission, } from "../../utils/permissions";
|
|
10
11
|
import { scale } from "../../styles/scale";
|
|
@@ -14,18 +15,34 @@ const ImagePicker = ({ mediaType, isMultiSelect = false, onSuccess, visible, onC
|
|
|
14
15
|
onClose();
|
|
15
16
|
}, [onSuccess, onClose]);
|
|
16
17
|
// Compress Image
|
|
18
|
+
// const compressImage = async (imagePath: string) => {
|
|
19
|
+
// if (!enableCompression) return imagePath;
|
|
20
|
+
// try {
|
|
21
|
+
// const compressedImage = await ImageCompressor.compress(imagePath, {
|
|
22
|
+
// maxWidth: imageCompressionOptions.maxWidth,
|
|
23
|
+
// quality: imageCompressionOptions.quality,
|
|
24
|
+
// });
|
|
25
|
+
// return compressedImage;
|
|
26
|
+
// } catch (error) {
|
|
27
|
+
// console.error("Image compression error:", error);
|
|
28
|
+
// return imagePath;
|
|
29
|
+
// }
|
|
30
|
+
// };
|
|
17
31
|
const compressImage = async (imagePath) => {
|
|
18
|
-
if (!enableCompression)
|
|
19
|
-
return imagePath;
|
|
20
32
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
if (!enableCompression)
|
|
34
|
+
return imagePath;
|
|
35
|
+
// STEP 1 — Resize using image resizer
|
|
36
|
+
const resized = await ImageResizer.createResizedImage(imagePath, imageCompressionOptions.maxWidth ?? 1080, imageCompressionOptions.maxWidth ?? 1080, "JPEG", (imageCompressionOptions.quality ?? 0.7) * 100, 0, undefined, false);
|
|
37
|
+
// STEP 2 — Compress using compressor
|
|
38
|
+
const compressedUri = await ImageCompressor.compress(resized.uri, {
|
|
39
|
+
maxWidth: imageCompressionOptions.maxWidth ?? 1080,
|
|
40
|
+
quality: imageCompressionOptions.quality ?? 0.7,
|
|
24
41
|
});
|
|
25
|
-
return
|
|
42
|
+
return compressedUri;
|
|
26
43
|
}
|
|
27
|
-
catch (
|
|
28
|
-
console.
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.log("Image final compression error:", err);
|
|
29
46
|
return imagePath;
|
|
30
47
|
}
|
|
31
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnhz/rn-ui-toolkit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"react-native-video-trim": "^3.0.9",
|
|
34
34
|
"react-native-compressor": "^1.13.0",
|
|
35
35
|
"react-native-fs": "^2.20.0",
|
|
36
|
-
"react-native-linear-gradient": "^2.8.3"
|
|
36
|
+
"react-native-linear-gradient": "^2.8.3",
|
|
37
|
+
"react-native-image-resizer":"^1.4.5"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@react-native-documents/picker": "^10.1.5",
|