@capgo/camera-preview 8.9.0 → 8.10.0
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 +5 -3
- package/android/src/main/java/app/capgo/capacitor/camera/preview/CameraPreview.java +4 -2
- package/android/src/main/java/app/capgo/capacitor/camera/preview/CameraXView.java +46 -4
- package/dist/docs.json +32 -0
- package/dist/esm/definitions.d.ts +16 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +2 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +2 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CameraController.swift +13 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +23 -11
- package/package.json +1 -1
|
@@ -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.
|
|
38
|
+
private let pluginVersion: String = "8.10.0"
|
|
39
39
|
public let identifier = "CameraPreviewPlugin"
|
|
40
40
|
public let jsName = "CameraPreview"
|
|
41
41
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -1265,10 +1265,11 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1265
1265
|
let width = call.getInt("width")
|
|
1266
1266
|
let height = call.getInt("height")
|
|
1267
1267
|
let photoQualityPrioritization = call.getString("photoQualityPrioritization", "speed")
|
|
1268
|
+
let mirrorFrontCamera = call.getBool("mirrorFrontCamera", false) ?? false
|
|
1268
1269
|
|
|
1269
1270
|
print("[CameraPreview] Raw parameter values - width: \(String(describing: width)), height: \(String(describing: height))")
|
|
1270
1271
|
|
|
1271
|
-
print("[CameraPreview] Capture params - quality: \(quality), saveToGallery: \(saveToGallery), withExifLocation: \(withExifLocation ?? false), embedTimestamp: \(embedTimestamp), embedLocation: \(effectiveEmbedLocation) (requested=\(embedLocationRequested)), width: \(width ?? -1), height: \(height ?? -1)")
|
|
1272
|
+
print("[CameraPreview] Capture params - quality: \(quality), saveToGallery: \(saveToGallery), withExifLocation: \(withExifLocation ?? false), embedTimestamp: \(embedTimestamp), embedLocation: \(effectiveEmbedLocation) (requested=\(embedLocationRequested)), width: \(width ?? -1), height: \(height ?? -1), mirrorFrontCamera: \(mirrorFrontCamera)")
|
|
1272
1273
|
print("[CameraPreview] Current location: \(self.currentLocation?.description ?? "nil")")
|
|
1273
1274
|
// Safely read frame from main thread for logging
|
|
1274
1275
|
let (previewWidth, previewHeight): (CGFloat, CGFloat) = {
|
|
@@ -1303,9 +1304,21 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1303
1304
|
return
|
|
1304
1305
|
}
|
|
1305
1306
|
|
|
1306
|
-
guard let
|
|
1307
|
-
|
|
1308
|
-
|
|
1307
|
+
guard let capturedImage = image else {
|
|
1308
|
+
print("[CameraPreview] Failed to create image data with EXIF")
|
|
1309
|
+
call.reject("Failed to create image data with EXIF")
|
|
1310
|
+
return
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
let imageToEncode: UIImage
|
|
1314
|
+
if mirrorFrontCamera, self.cameraPosition == "front" {
|
|
1315
|
+
imageToEncode = self.cameraController.mirrorImageHorizontally(capturedImage)
|
|
1316
|
+
} else {
|
|
1317
|
+
imageToEncode = capturedImage
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
guard let imageDataWithExif = self.createImageDataWithExif(
|
|
1321
|
+
from: imageToEncode,
|
|
1309
1322
|
quality: Int(quality),
|
|
1310
1323
|
location: withExifLocation ? self.currentLocation : nil,
|
|
1311
1324
|
heading: withExifLocation ? self.currentHeading : nil,
|
|
@@ -1520,6 +1533,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1520
1533
|
|
|
1521
1534
|
@objc func captureSample(_ call: CAPPluginCall) {
|
|
1522
1535
|
let quality: Int = call.getInt("quality") ?? 85
|
|
1536
|
+
let mirrorFrontCamera = call.getBool("mirrorFrontCamera", false) ?? false
|
|
1523
1537
|
|
|
1524
1538
|
self.cameraController.captureSample { image, error in
|
|
1525
1539
|
guard let image = image else {
|
|
@@ -1528,13 +1542,11 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1528
1542
|
return
|
|
1529
1543
|
}
|
|
1530
1544
|
|
|
1531
|
-
|
|
1532
|
-
if self.cameraPosition == "front" {
|
|
1533
|
-
|
|
1534
|
-
imageData = flippedImage.jpegData(compressionQuality: CGFloat(quality)/100)
|
|
1535
|
-
} else {
|
|
1536
|
-
imageData = image.jpegData(compressionQuality: CGFloat(quality)/100)
|
|
1545
|
+
var outputImage = image
|
|
1546
|
+
if mirrorFrontCamera, self.cameraPosition == "front" {
|
|
1547
|
+
outputImage = self.cameraController.mirrorImageHorizontally(image)
|
|
1537
1548
|
}
|
|
1549
|
+
let imageData = outputImage.jpegData(compressionQuality: CGFloat(quality)/100)
|
|
1538
1550
|
|
|
1539
1551
|
if self.storeToFile == false {
|
|
1540
1552
|
guard let imageBase64 = imageData?.base64EncodedString() else {
|