@capgo/camera-preview 8.13.2 → 8.13.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.
@@ -1635,10 +1635,6 @@ extension CameraController {
1635
1635
  return
1636
1636
  }
1637
1637
 
1638
- if let location = gpsLocation {
1639
- self.addGPSMetadata(to: image, location: location)
1640
- }
1641
-
1642
1638
  var finalImage = image
1643
1639
 
1644
1640
  // Determine what to do based on parameters
@@ -1906,35 +1902,6 @@ extension CameraController {
1906
1902
  return newJPEG
1907
1903
  }
1908
1904
 
1909
- func addGPSMetadata(to image: UIImage, location: CLLocation) {
1910
- guard let jpegData = image.jpegData(compressionQuality: 1.0),
1911
- let source = CGImageSourceCreateWithData(jpegData as CFData, nil),
1912
- let uti = CGImageSourceGetType(source) else { return }
1913
-
1914
- var metadata = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [String: Any] ?? [:]
1915
-
1916
- let formatter = DateFormatter()
1917
- formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
1918
- formatter.timeZone = TimeZone(abbreviation: "UTC")
1919
-
1920
- let gpsDict: [String: Any] = [
1921
- kCGImagePropertyGPSLatitude as String: abs(location.coordinate.latitude),
1922
- kCGImagePropertyGPSLatitudeRef as String: location.coordinate.latitude >= 0 ? "N" : "S",
1923
- kCGImagePropertyGPSLongitude as String: abs(location.coordinate.longitude),
1924
- kCGImagePropertyGPSLongitudeRef as String: location.coordinate.longitude >= 0 ? "E" : "W",
1925
- kCGImagePropertyGPSTimeStamp as String: formatter.string(from: location.timestamp),
1926
- kCGImagePropertyGPSAltitude as String: location.altitude,
1927
- kCGImagePropertyGPSAltitudeRef as String: location.altitude >= 0 ? 0 : 1
1928
- ]
1929
-
1930
- metadata[kCGImagePropertyGPSDictionary as String] = gpsDict
1931
-
1932
- let destData = NSMutableData()
1933
- guard let destination = CGImageDestinationCreateWithData(destData, uti, 1, nil) else { return }
1934
- CGImageDestinationAddImageFromSource(destination, source, 0, metadata as CFDictionary)
1935
- CGImageDestinationFinalize(destination)
1936
- }
1937
-
1938
1905
  func resizeImage(image: UIImage, to size: CGSize) -> UIImage? {
1939
1906
  // Create a renderer with scale 1.0 to ensure we get exact pixel dimensions
1940
1907
  let format = UIGraphicsImageRendererFormat()
@@ -35,7 +35,7 @@ extension UIWindow {
35
35
  */
36
36
  @objc(CameraPreview)
37
37
  public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
38
- private let pluginVersion: String = "8.13.2"
38
+ private let pluginVersion: String = "8.13.3"
39
39
  public let identifier = "CameraPreviewPlugin"
40
40
  public let jsName = "CameraPreview"
41
41
  public let pluginMethods: [CAPPluginMethod] = [
@@ -29,6 +29,53 @@ final class CaptureImageExifEncoderTests: XCTestCase {
29
29
  XCTAssertEqual(encodeCallCount, 0)
30
30
  }
31
31
 
32
+ func testWritesGpsMetadataWhenLocationProvided() {
33
+ let image = makeTestImage()
34
+ guard let originalPhotoData = image.jpegData(compressionQuality: 0.9) else {
35
+ XCTFail("Failed to build fixture JPEG")
36
+ return
37
+ }
38
+
39
+ let location = CLLocation(
40
+ coordinate: CLLocationCoordinate2D(latitude: 32.65, longitude: -16.91),
41
+ altitude: 100,
42
+ horizontalAccuracy: 5,
43
+ verticalAccuracy: 5,
44
+ timestamp: Date(timeIntervalSince1970: 1_700_000_000)
45
+ )
46
+
47
+ let result = CaptureImageExifEncoder.createImageData(
48
+ from: image,
49
+ quality: 85,
50
+ location: location,
51
+ heading: nil,
52
+ originalPhotoData: originalPhotoData
53
+ )
54
+
55
+ guard let result,
56
+ let source = CGImageSourceCreateWithData(result as CFData, nil),
57
+ let properties = CGImageSourceCopyPropertiesAtIndex(source, 0, nil) as? [String: Any],
58
+ let gps = properties[kCGImagePropertyGPSDictionary as String] as? [String: Any] else {
59
+ XCTFail("Expected JPEG output with GPS metadata")
60
+ return
61
+ }
62
+
63
+ guard let latitude = gps[kCGImagePropertyGPSLatitude as String] as? Double,
64
+ let longitude = gps[kCGImagePropertyGPSLongitude as String] as? Double,
65
+ let altitude = gps[kCGImagePropertyGPSAltitude as String] as? Double else {
66
+ XCTFail("Expected GPS latitude, longitude, and altitude as Double")
67
+ return
68
+ }
69
+
70
+ XCTAssertEqual(latitude, 32.65, accuracy: 0.0001)
71
+ XCTAssertEqual(gps[kCGImagePropertyGPSLatitudeRef as String] as? String, "N")
72
+ XCTAssertEqual(longitude, 16.91, accuracy: 0.0001)
73
+ XCTAssertEqual(gps[kCGImagePropertyGPSLongitudeRef as String] as? String, "W")
74
+ XCTAssertEqual(altitude, 100, accuracy: 0.0001)
75
+ XCTAssertEqual(gps[kCGImagePropertyGPSAltitudeRef as String] as? Int, 0)
76
+ XCTAssertNotNil(gps[kCGImagePropertyGPSTimeStamp as String] as? String)
77
+ }
78
+
32
79
  func testProducesJpegWithTiffMetadata() {
33
80
  let image = makeTestImage()
34
81
  guard let originalPhotoData = image.jpegData(compressionQuality: 0.9) else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "8.13.2",
3
+ "version": "8.13.3",
4
4
  "description": "Camera preview",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {