react-native-compressor 1.13.0 → 1.14.0
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.
- package/android/build.gradle +1 -1
- package/ios/Image/ImageMain.swift +40 -16
- package/ios/Utils/Utils.swift +2 -0
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -115,7 +115,7 @@ dependencies {
|
|
|
115
115
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
|
|
116
116
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
|
|
117
117
|
implementation 'org.mp4parser:isoparser:1.9.56'
|
|
118
|
-
implementation 'com.github.
|
|
118
|
+
implementation 'com.github.kaushik-naik:TAndroidLame:277c2ab4b0'
|
|
119
119
|
implementation 'javazoom:jlayer:1.0.1'
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -28,23 +28,47 @@ class ImageMain {
|
|
|
28
28
|
static func getImageMetaData(_ filePath: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
29
29
|
let options = ImageCompressorOptions.fromDictionary([:])
|
|
30
30
|
ImageCompressor.getAbsoluteImagePath(filePath, options: options) { ImagePath in
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
guard ImagePath.hasPrefix("file://") else {
|
|
32
|
+
reject("INVALID_PATH", "Image path must start with file://", nil)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
guard let url = URL(string: ImagePath) else {
|
|
37
|
+
reject("INVALID_URL", "Failed to create URL from image path", nil)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let absoluteImagePath = url.path
|
|
42
|
+
let fileURL = url as CFURL
|
|
43
|
+
|
|
44
|
+
Utils.getFileSize(absoluteImagePath) { fileSize in
|
|
45
|
+
let _extension = (absoluteImagePath as NSString).pathExtension
|
|
46
|
+
|
|
47
|
+
// Use CGImageSourceCreateWithURL to avoid loading entire file into memory (prevents OOM crashes for large images)
|
|
48
|
+
guard let imageSource = CGImageSourceCreateWithURL(fileURL, nil) else {
|
|
49
|
+
reject("INVALID_IMAGE", "Failed to create image source from URL", nil)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
guard let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) else {
|
|
54
|
+
reject("NO_PROPERTIES", "Failed to get image properties", nil)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let exif = imageProperties as NSDictionary
|
|
59
|
+
guard let mutableExif = exif.mutableCopy() as? NSMutableDictionary else {
|
|
60
|
+
reject("COPY_ERROR", "Failed to create mutable copy of image properties", nil)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if let fileSizeString = fileSize as? String, let fileSizeInt = Int(fileSizeString) {
|
|
65
|
+
mutableExif.setValue(fileSizeInt, forKey: "size")
|
|
47
66
|
}
|
|
67
|
+
|
|
68
|
+
mutableExif.setValue(_extension, forKey: "extension")
|
|
69
|
+
resolve(mutableExif)
|
|
70
|
+
} reject: { code, message, error in
|
|
71
|
+
reject(code, message, error)
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
}
|
package/ios/Utils/Utils.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-compressor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|