@capgo/camera-preview 7.13.6 → 7.13.7
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.
|
@@ -789,23 +789,21 @@ extension CameraController {
|
|
|
789
789
|
}
|
|
790
790
|
|
|
791
791
|
func captureImage(width: Int?, height: Int?, quality: Float, gpsLocation: CLLocation?, completion: @escaping (UIImage?, Data?, [AnyHashable: Any]?, Error?) -> Void) {
|
|
792
|
-
print("[CameraPreview] captureImage called - width: \(width ?? -1), height: \(height ?? -1), requestedAspectRatio: \(self.requestedAspectRatio ?? "nil")")
|
|
793
|
-
|
|
794
792
|
guard let photoOutput = self.photoOutput else {
|
|
795
793
|
completion(nil, nil, nil, NSError(domain: "Camera", code: 0, userInfo: [NSLocalizedDescriptionKey: "Photo output is not available"]))
|
|
796
794
|
return
|
|
797
795
|
}
|
|
798
796
|
|
|
799
797
|
let settings = AVCapturePhotoSettings()
|
|
800
|
-
// Configure photo capture settings
|
|
798
|
+
// Configure photo capture settings optimized for speed
|
|
801
799
|
if #available(iOS 13.0, *) {
|
|
802
|
-
//
|
|
803
|
-
|
|
804
|
-
let shouldUseHighRes = (width != nil || height != nil) || (self.requestedAspectRatio == nil)
|
|
800
|
+
// Only use high res if explicitly requesting large dimensions
|
|
801
|
+
let shouldUseHighRes = width.map { $0 > 1920 } ?? false || height.map { $0 > 1920 } ?? false
|
|
805
802
|
settings.isHighResolutionPhotoEnabled = shouldUseHighRes
|
|
806
803
|
}
|
|
807
804
|
if #available(iOS 15.0, *) {
|
|
808
|
-
|
|
805
|
+
// Prioritize speed over quality
|
|
806
|
+
settings.photoQualityPrioritization = .speed
|
|
809
807
|
}
|
|
810
808
|
|
|
811
809
|
// Apply the current flash mode to the photo settings
|
|
@@ -1965,20 +1963,30 @@ extension CameraController: AVCapturePhotoCaptureDelegate {
|
|
|
1965
1963
|
return
|
|
1966
1964
|
}
|
|
1967
1965
|
|
|
1968
|
-
//
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1966
|
+
// Process photo in background to avoid blocking main thread
|
|
1967
|
+
DispatchQueue.global(qos: .userInitiated).async {
|
|
1968
|
+
// Get the photo data using the modern API
|
|
1969
|
+
guard let imageData = photo.fileDataRepresentation() else {
|
|
1970
|
+
DispatchQueue.main.async {
|
|
1971
|
+
self.photoCaptureCompletionBlock?(nil, nil, nil, CameraControllerError.unknown)
|
|
1972
|
+
}
|
|
1973
|
+
return
|
|
1974
|
+
}
|
|
1973
1975
|
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1976
|
+
// Create image from data
|
|
1977
|
+
guard let image = UIImage(data: imageData) else {
|
|
1978
|
+
DispatchQueue.main.async {
|
|
1979
|
+
self.photoCaptureCompletionBlock?(nil, nil, nil, CameraControllerError.unknown)
|
|
1980
|
+
}
|
|
1981
|
+
return
|
|
1982
|
+
}
|
|
1978
1983
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1984
|
+
// Pass through original file data and metadata so callers can preserve EXIF
|
|
1985
|
+
// Don't call fixedOrientation() here - let the completion block handle it after cropping
|
|
1986
|
+
DispatchQueue.main.async {
|
|
1987
|
+
self.photoCaptureCompletionBlock?(image, imageData, photo.metadata, nil)
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1982
1990
|
}
|
|
1983
1991
|
}
|
|
1984
1992
|
|