Skip to content

Commit

Permalink
made the properties optional so it won't throw an error if they are n…
Browse files Browse the repository at this point in the history
…ot complete
  • Loading branch information
Rafael Haußmann committed Aug 23, 2024
1 parent 111b6b3 commit 7e4b2ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
34 changes: 19 additions & 15 deletions ios/ExifModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,25 @@ class ExifModifier: NSObject {


@objc func saveImageWithProperties(_ base64ImageData: String, properties: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
let mappedProperties: NSDictionary = [
kCGImagePropertyExifDictionary as String: [
kCGImagePropertyExifUserComment as String: properties["UserComment"] as! String
],
kCGImagePropertyGPSDictionary as String: [
kCGImagePropertyGPSLatitude as String: properties["GPSLatitude"] as! String,
kCGImagePropertyGPSLatitudeRef as String: properties["GPSLatitudeRef"] as! String,
kCGImagePropertyGPSLongitude as String: properties["GPSLongitude"] as! String,
kCGImagePropertyGPSLongitudeRef as String: properties["GPSLongitudeRef"] as! String,
kCGImagePropertyGPSAltitude as String: properties["GPSAltitude"] as! String,
kCGImagePropertyGPSAltitudeRef as String: properties["GPSAltitudeRef"] as! String,
kCGImagePropertyGPSTimeStamp as String: properties["GPSTimeStamp"] as! String,
kCGImagePropertyGPSDateStamp as String: properties["GPSDateStamp"] as! String,
]
]
let exifProperties: [String: Any] = [
kCGImagePropertyExifUserComment as String: properties["UserComment"]
].compactMapValues { $0 }

let gpsProperties: [String: Any] = [
kCGImagePropertyGPSLatitude as String: properties["GPSLatitude"],
kCGImagePropertyGPSLatitudeRef as String: properties["GPSLatitudeRef"],
kCGImagePropertyGPSLongitude as String: properties["GPSLongitude"],
kCGImagePropertyGPSLongitudeRef as String: properties["GPSLongitudeRef"],
kCGImagePropertyGPSAltitude as String: properties["GPSAltitude"],
kCGImagePropertyGPSAltitudeRef as String: properties["GPSAltitudeRef"],
kCGImagePropertyGPSTimeStamp as String: properties["GPSTimeStamp"],
kCGImagePropertyGPSDateStamp as String: properties["GPSDateStamp"]
].compactMapValues { $0 }

let mappedProperties: NSDictionary = [
kCGImagePropertyExifDictionary as String: exifProperties,
kCGImagePropertyGPSDictionary as String: gpsProperties
]

saveImageAndModifyProperties(base64ImageData, properties: mappedProperties, resolve: resolve, reject: reject)
}
Expand Down
8 changes: 4 additions & 4 deletions src/interfaces/ImageProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

export interface ImageProperties {
UserComment?: string;
GPSLatitude?: number;
GPSLatitude?: string;
GPSLatitudeRef?: string;
GPSLongitude?: number;
GPSLongitude?: string;
GPSLongitudeRef?: string;
GPSAltitude?: number;
GPSAltitude?: string;
GPSAltitudeRef?: string;
GPSTimeStamp?: string;
GPSDateStamp?: string;
}
}

0 comments on commit 7e4b2ad

Please sign in to comment.