@lodev09/react-native-exify 0.2.2 → 0.2.3
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/README.md +4 -4
- package/ios/ExifyUtils.swift +10 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,11 +42,11 @@ const result = await writeAsync(uri, newTags)
|
|
|
42
42
|
console.log(result.tags)
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
> **Note**:
|
|
46
|
+
> On IOS, writing exif into an Asset file will duplicate the image. IOS does not allow writing exif into an Asset file directly.
|
|
47
|
+
> If you're getting the photo from a [camera](https://github.com/mrousavy/react-native-vision-camera/), write it into the output file first before saving to the Asset library!
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
See [example](example) for more detailed usage.
|
|
50
50
|
|
|
51
51
|
## Contributing
|
|
52
52
|
Contributions are welcome!
|
package/ios/ExifyUtils.swift
CHANGED
|
@@ -64,6 +64,7 @@ func getExifTags(from metadata: NSDictionary) -> [String: Any] {
|
|
|
64
64
|
func readExifTags(from url: URL?, completionHandler: ([String: Any]?) -> Void) -> Void {
|
|
65
65
|
guard let url, let sourceImage = CGImageSourceCreateWithURL(url as CFURL, nil),
|
|
66
66
|
let metadataDict = CGImageSourceCopyPropertiesAtIndex(sourceImage, 0, nil) else {
|
|
67
|
+
completionHandler(nil)
|
|
67
68
|
return
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -73,6 +74,7 @@ func readExifTags(from url: URL?, completionHandler: ([String: Any]?) -> Void) -
|
|
|
73
74
|
|
|
74
75
|
func updateMetadata(url: URL, with tags: [String: Any], completionHanlder: (NSDictionary?, Data?) -> Void) -> Void {
|
|
75
76
|
guard let cgImageSource = CGImageSourceCreateWithURL(url as CFURL, nil) else {
|
|
77
|
+
completionHanlder(nil, nil)
|
|
76
78
|
return
|
|
77
79
|
}
|
|
78
80
|
|
|
@@ -81,7 +83,7 @@ func updateMetadata(url: URL, with tags: [String: Any], completionHanlder: (NSDi
|
|
|
81
83
|
|
|
82
84
|
// Append additional Exif data
|
|
83
85
|
let exifDict = metadata[kCGImagePropertyExifDictionary as String] as? NSMutableDictionary
|
|
84
|
-
exifDict
|
|
86
|
+
exifDict?.addEntries(from: tags)
|
|
85
87
|
|
|
86
88
|
// Handle GPS Tags
|
|
87
89
|
var gpsDict = [String: Any]()
|
|
@@ -122,14 +124,15 @@ func updateMetadata(url: URL, with tags: [String: Any], completionHanlder: (NSDi
|
|
|
122
124
|
|
|
123
125
|
let destinationData = NSMutableData()
|
|
124
126
|
|
|
125
|
-
guard let
|
|
127
|
+
guard let uiImage = UIImage(contentsOfFile: url.path),
|
|
128
|
+
let sourceType = CGImageSourceGetType(cgImageSource),
|
|
126
129
|
let destination = CGImageDestinationCreateWithData(destinationData, sourceType, 1, nil) else {
|
|
130
|
+
completionHanlder(nil, nil)
|
|
127
131
|
return
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
CGImageDestinationAddImage(destination, uiImage.cgImage!, metadata)
|
|
135
|
+
CGImageDestinationFinalize(destination)
|
|
136
|
+
|
|
137
|
+
completionHanlder(metadata, destinationData as Data)
|
|
134
138
|
}
|
|
135
|
-
|