react-native-compressor 1.8.21 → 1.8.22
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.
|
@@ -125,16 +125,25 @@ class ImageCompressor {
|
|
|
125
125
|
|
|
126
126
|
let url = URL(fileURLWithPath: filePath)
|
|
127
127
|
let source = CGImageSourceCreateWithURL(url as CFURL, nil)!
|
|
128
|
-
|
|
128
|
+
let metadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [CFString: Any]
|
|
129
129
|
|
|
130
130
|
let dataProvider = CGDataProvider(data: data as CFData)
|
|
131
131
|
let dataImageSource = CGImageSourceCreateWithDataProvider(dataProvider!, nil)!
|
|
132
|
-
|
|
132
|
+
var dataMetadata = CGImageSourceCopyPropertiesAtIndex(dataImageSource, 0, nil) as? [CFString: Any]
|
|
133
133
|
|
|
134
134
|
// Copy all keys from source metadata to destination metadata if they don't exist
|
|
135
|
-
for (key, value) in
|
|
136
|
-
if
|
|
137
|
-
|
|
135
|
+
for (key, value) in metadata ?? [:] {
|
|
136
|
+
if dataMetadata?[key] == nil {
|
|
137
|
+
dataMetadata?[key] = value
|
|
138
|
+
} else {
|
|
139
|
+
if let metadataObj = dataMetadata?[key] as? NSMutableDictionary,
|
|
140
|
+
let valueObj = value as? NSDictionary {
|
|
141
|
+
for (key, value) in valueObj {
|
|
142
|
+
if metadataObj[key] == nil {
|
|
143
|
+
metadataObj[key] = value
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
149
|
|
|
@@ -142,7 +151,7 @@ class ImageCompressor {
|
|
|
142
151
|
|
|
143
152
|
let destinationData = NSMutableData()
|
|
144
153
|
let destination = CGImageDestinationCreateWithData(destinationData, outputFormat, 1, nil)!
|
|
145
|
-
CGImageDestinationAddImage(destination, image.cgImage!,
|
|
154
|
+
CGImageDestinationAddImage(destination, image.cgImage!, dataMetadata as CFDictionary?)
|
|
146
155
|
CGImageDestinationFinalize(destination)
|
|
147
156
|
return destinationData as Data
|
|
148
157
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-compressor",
|
|
3
|
-
"version": "1.8.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.8.22",
|
|
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",
|
|
7
7
|
"types": "lib/typescript/index.d.ts",
|