@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 CHANGED
@@ -42,11 +42,11 @@ const result = await writeAsync(uri, newTags)
42
42
  console.log(result.tags)
43
43
  ```
44
44
 
45
- See [example](example) for more detailed usage.
46
-
47
- ℹ️ Note that on IOS, writing exif into an Asset file will duplicate the image. IOS does not allow writing exif into an Asset file directly.
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
- 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!
49
+ See [example](example) for more detailed usage.
50
50
 
51
51
  ## Contributing
52
52
  Contributions are welcome!
@@ -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!.addEntries(from: tags)
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 sourceType = CGImageSourceGetType(cgImageSource),
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
- CGImageDestinationAddImageFromSource(destination, cgImageSource, 0, metadata)
131
- if CGImageDestinationFinalize(destination) {
132
- completionHanlder(metadata, destinationData as Data)
133
- }
134
+ CGImageDestinationAddImage(destination, uiImage.cgImage!, metadata)
135
+ CGImageDestinationFinalize(destination)
136
+
137
+ completionHanlder(metadata, destinationData as Data)
134
138
  }
135
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodev09/react-native-exify",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Read and write exif data into an image.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",