@capgo/camera-preview 7.4.0-beta.1 → 7.4.0-beta.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.
@@ -4,7 +4,6 @@ import android.content.Context;
4
4
  import android.hardware.camera2.CameraAccessException;
5
5
  import android.hardware.camera2.CameraManager;
6
6
  import android.os.Build;
7
- import android.os.HandlerThread;
8
7
  import android.util.Base64;
9
8
  import android.util.Log;
10
9
  import android.util.Size;
@@ -32,29 +31,42 @@ import com.ahm.capacitor.camera.preview.model.LensInfo;
32
31
  import com.ahm.capacitor.camera.preview.model.ZoomFactors;
33
32
  import com.google.common.util.concurrent.ListenableFuture;
34
33
  import java.nio.ByteBuffer;
35
- import java.nio.file.Files;
36
34
  import java.util.Arrays;
37
35
  import java.util.Collections;
38
36
  import java.util.List;
39
37
  import java.util.ArrayList;
40
38
  import java.util.Objects;
41
- import java.util.concurrent.ExecutionException;
42
39
  import java.util.concurrent.Executor;
43
40
  import java.util.concurrent.ExecutorService;
44
41
  import java.util.concurrent.Executors;
45
42
  import androidx.camera.camera2.interop.Camera2CameraInfo;
46
43
  import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
47
44
  import android.hardware.camera2.CameraCharacteristics;
48
- import androidx.camera.extensions.ExtensionMode;
49
45
  import java.util.Set;
50
46
  import androidx.camera.core.ZoomState;
51
47
  import androidx.camera.core.ResolutionInfo;
48
+ import android.content.Intent;
49
+ import android.net.Uri;
50
+ import android.os.Environment;
51
+ import java.io.File;
52
+ import java.io.FileOutputStream;
53
+ import java.io.IOException;
54
+ import java.text.SimpleDateFormat;
55
+ import java.util.Locale;
56
+ import androidx.exifinterface.media.ExifInterface;
57
+ import org.json.JSONObject;
58
+ import java.nio.file.Files;
59
+ import android.graphics.BitmapFactory;
60
+ import android.graphics.Bitmap;
61
+ import android.graphics.Matrix;
62
+ import java.io.ByteArrayOutputStream;
63
+ import android.location.Location;
52
64
 
53
65
  public class CameraXView implements LifecycleOwner {
54
66
  private static final String TAG = "CameraPreview CameraXView";
55
67
 
56
68
  public interface CameraXViewListener {
57
- void onPictureTaken(String result);
69
+ void onPictureTaken(String base64, JSONObject exif);
58
70
  void onPictureTakenError(String message);
59
71
  void onSampleTaken(String result);
60
72
  void onSampleTakenError(String message);
@@ -102,6 +114,26 @@ public class CameraXView implements LifecycleOwner {
102
114
  return isRunning;
103
115
  }
104
116
 
117
+ private void saveImageToGallery(byte[] data) {
118
+ try {
119
+ File photo = new File(
120
+ Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
121
+ "IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new java.util.Date()) + ".jpg"
122
+ );
123
+ FileOutputStream fos = new FileOutputStream(photo);
124
+ fos.write(data);
125
+ fos.close();
126
+
127
+ // Notify the gallery of the new image
128
+ Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
129
+ Uri contentUri = Uri.fromFile(photo);
130
+ mediaScanIntent.setData(contentUri);
131
+ context.sendBroadcast(mediaScanIntent);
132
+ } catch (IOException e) {
133
+ Log.e(TAG, "Error saving image to gallery", e);
134
+ }
135
+ }
136
+
105
137
  public void startSession(CameraSessionConfiguration config) {
106
138
  this.sessionConfig = config;
107
139
  cameraExecutor = Executors.newSingleThreadExecutor();
@@ -167,6 +199,7 @@ public class CameraXView implements LifecycleOwner {
167
199
  webView.setBackgroundColor(android.graphics.Color.WHITE);
168
200
  }
169
201
 
202
+ @OptIn(markerClass = ExperimentalCamera2Interop.class)
170
203
  private void bindCameraUseCases() {
171
204
  if (cameraProvider == null) return;
172
205
  mainExecutor.execute(() -> {
@@ -188,7 +221,6 @@ public class CameraXView implements LifecycleOwner {
188
221
  Log.d(TAG, "Use cases bound. Inspecting active camera and use cases.");
189
222
  CameraInfo cameraInfo = camera.getCameraInfo();
190
223
  Log.d(TAG, "Bound Camera ID: " + Camera2CameraInfo.from(cameraInfo).getCameraId());
191
- Log.d(TAG, "Implementation Type: " + cameraInfo.getImplementationType());
192
224
 
193
225
  // Log zoom state
194
226
  ZoomState zoomState = cameraInfo.getZoomState().getValue();
@@ -256,22 +288,6 @@ public class CameraXView implements LifecycleOwner {
256
288
  return builder.build();
257
289
  }
258
290
 
259
- private static boolean isIsLogical(CameraManager cameraManager, String cameraId) throws CameraAccessException {
260
- CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
261
- int[] capabilities = characteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
262
-
263
- boolean isLogical = false;
264
- if (capabilities != null) {
265
- for (int capability : capabilities) {
266
- if (capability == CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
267
- isLogical = true;
268
- break;
269
- }
270
- }
271
- }
272
- return isLogical;
273
- }
274
-
275
291
  private static String getCameraId(androidx.camera.core.CameraInfo cameraInfo) {
276
292
  try {
277
293
  // Generate a stable ID based on camera characteristics
@@ -303,7 +319,7 @@ public class CameraXView implements LifecycleOwner {
303
319
  }
304
320
  }
305
321
 
306
- public void capturePhoto(int quality) {
322
+ public void capturePhoto(int quality, final boolean saveToGallery, Integer width, Integer height, Location location) {
307
323
  Log.d(TAG, "capturePhoto: Starting photo capture with quality: " + quality);
308
324
 
309
325
  if (imageCapture == null) {
@@ -313,9 +329,8 @@ public class CameraXView implements LifecycleOwner {
313
329
  return;
314
330
  }
315
331
 
316
- ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(
317
- new java.io.File(context.getCacheDir(), "temp_image.jpg")
318
- ).build();
332
+ File tempFile = new File(context.getCacheDir(), "temp_image.jpg");
333
+ ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(tempFile).build();
319
334
 
320
335
  imageCapture.takePicture(
321
336
  outputFileOptions,
@@ -331,31 +346,37 @@ public class CameraXView implements LifecycleOwner {
331
346
 
332
347
  @Override
333
348
  public void onImageSaved(@NonNull ImageCapture.OutputFileResults output) {
334
- // Convert to base64
335
349
  try {
336
- java.io.File tempFile = new java.io.File(context.getCacheDir(), "temp_image.jpg");
337
- byte[] bytes;
338
-
339
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
340
- bytes = Files.readAllBytes(tempFile.toPath());
341
- } else {
342
- // Fallback for older Android versions
343
- java.io.FileInputStream fis = new java.io.FileInputStream(tempFile);
344
- bytes = new byte[(int) tempFile.length()];
345
- fis.read(bytes);
346
- fis.close();
350
+ byte[] bytes = Files.readAllBytes(tempFile.toPath());
351
+ ExifInterface exifInterface = new ExifInterface(tempFile.getAbsolutePath());
352
+
353
+ if (location != null) {
354
+ exifInterface.setGpsInfo(location);
355
+ }
356
+
357
+ JSONObject exifData = getExifData(exifInterface);
358
+
359
+ if (width != null && height != null) {
360
+ Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
361
+ Bitmap resizedBitmap = resizeBitmap(bitmap, width, height);
362
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
363
+ resizedBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
364
+ bytes = stream.toByteArray();
365
+ }
366
+
367
+ if (saveToGallery) {
368
+ saveImageToGallery(bytes);
347
369
  }
348
370
 
349
371
  String base64 = Base64.encodeToString(bytes, Base64.NO_WRAP);
350
-
351
- // Clean up temp file
372
+
352
373
  tempFile.delete();
353
374
 
354
375
  if (listener != null) {
355
- listener.onPictureTaken(base64);
376
+ listener.onPictureTaken(base64, exifData);
356
377
  }
357
378
  } catch (Exception e) {
358
- Log.e(TAG, "capturePhoto: Error converting to base64", e);
379
+ Log.e(TAG, "capturePhoto: Error processing image", e);
359
380
  if (listener != null) {
360
381
  listener.onPictureTakenError("Error processing image: " + e.getMessage());
361
382
  }
@@ -365,6 +386,170 @@ public class CameraXView implements LifecycleOwner {
365
386
  );
366
387
  }
367
388
 
389
+ private Bitmap resizeBitmap(Bitmap bitmap, int width, int height) {
390
+ return Bitmap.createScaledBitmap(bitmap, width, height, true);
391
+ }
392
+
393
+ private JSONObject getExifData(ExifInterface exifInterface) {
394
+ JSONObject exifData = new JSONObject();
395
+ try {
396
+ // Add all available exif tags to a JSON object
397
+ for (String[] tag : EXIF_TAGS) {
398
+ String value = exifInterface.getAttribute(tag[0]);
399
+ if (value != null) {
400
+ exifData.put(tag[1], value);
401
+ }
402
+ }
403
+ } catch (Exception e) {
404
+ Log.e(TAG, "getExifData: Error reading exif data", e);
405
+ }
406
+ return exifData;
407
+ }
408
+
409
+ private static final String[][] EXIF_TAGS = new String[][]{
410
+ {ExifInterface.TAG_APERTURE_VALUE, "ApertureValue"},
411
+ {ExifInterface.TAG_ARTIST, "Artist"},
412
+ {ExifInterface.TAG_BITS_PER_SAMPLE, "BitsPerSample"},
413
+ {ExifInterface.TAG_BRIGHTNESS_VALUE, "BrightnessValue"},
414
+ {ExifInterface.TAG_CFA_PATTERN, "CFAPattern"},
415
+ {ExifInterface.TAG_COLOR_SPACE, "ColorSpace"},
416
+ {ExifInterface.TAG_COMPONENTS_CONFIGURATION, "ComponentsConfiguration"},
417
+ {ExifInterface.TAG_COMPRESSED_BITS_PER_PIXEL, "CompressedBitsPerPixel"},
418
+ {ExifInterface.TAG_COMPRESSION, "Compression"},
419
+ {ExifInterface.TAG_CONTRAST, "Contrast"},
420
+ {ExifInterface.TAG_COPYRIGHT, "Copyright"},
421
+ {ExifInterface.TAG_CUSTOM_RENDERED, "CustomRendered"},
422
+ {ExifInterface.TAG_DATETIME, "DateTime"},
423
+ {ExifInterface.TAG_DATETIME_DIGITIZED, "DateTimeDigitized"},
424
+ {ExifInterface.TAG_DATETIME_ORIGINAL, "DateTimeOriginal"},
425
+ {ExifInterface.TAG_DEVICE_SETTING_DESCRIPTION, "DeviceSettingDescription"},
426
+ {ExifInterface.TAG_DIGITAL_ZOOM_RATIO, "DigitalZoomRatio"},
427
+ {ExifInterface.TAG_DNG_VERSION, "DNGVersion"},
428
+ {ExifInterface.TAG_EXIF_VERSION, "ExifVersion"},
429
+ {ExifInterface.TAG_EXPOSURE_BIAS_VALUE, "ExposureBiasValue"},
430
+ {ExifInterface.TAG_EXPOSURE_INDEX, "ExposureIndex"},
431
+ {ExifInterface.TAG_EXPOSURE_MODE, "ExposureMode"},
432
+ {ExifInterface.TAG_EXPOSURE_PROGRAM, "ExposureProgram"},
433
+ {ExifInterface.TAG_EXPOSURE_TIME, "ExposureTime"},
434
+ {ExifInterface.TAG_FILE_SOURCE, "FileSource"},
435
+ {ExifInterface.TAG_FLASH, "Flash"},
436
+ {ExifInterface.TAG_FLASHPIX_VERSION, "FlashpixVersion"},
437
+ {ExifInterface.TAG_FLASH_ENERGY, "FlashEnergy"},
438
+ {ExifInterface.TAG_FOCAL_LENGTH, "FocalLength"},
439
+ {ExifInterface.TAG_FOCAL_LENGTH_IN_35MM_FILM, "FocalLengthIn35mmFilm"},
440
+ {ExifInterface.TAG_FOCAL_PLANE_RESOLUTION_UNIT, "FocalPlaneResolutionUnit"},
441
+ {ExifInterface.TAG_FOCAL_PLANE_X_RESOLUTION, "FocalPlaneXResolution"},
442
+ {ExifInterface.TAG_FOCAL_PLANE_Y_RESOLUTION, "FocalPlaneYResolution"},
443
+ {ExifInterface.TAG_F_NUMBER, "FNumber"},
444
+ {ExifInterface.TAG_GAIN_CONTROL, "GainControl"},
445
+ {ExifInterface.TAG_GPS_ALTITUDE, "GPSAltitude"},
446
+ {ExifInterface.TAG_GPS_ALTITUDE_REF, "GPSAltitudeRef"},
447
+ {ExifInterface.TAG_GPS_AREA_INFORMATION, "GPSAreaInformation"},
448
+ {ExifInterface.TAG_GPS_DATESTAMP, "GPSDateStamp"},
449
+ {ExifInterface.TAG_GPS_DEST_BEARING, "GPSDestBearing"},
450
+ {ExifInterface.TAG_GPS_DEST_BEARING_REF, "GPSDestBearingRef"},
451
+ {ExifInterface.TAG_GPS_DEST_DISTANCE, "GPSDestDistance"},
452
+ {ExifInterface.TAG_GPS_DEST_DISTANCE_REF, "GPSDestDistanceRef"},
453
+ {ExifInterface.TAG_GPS_DEST_LATITUDE, "GPSDestLatitude"},
454
+ {ExifInterface.TAG_GPS_DEST_LATITUDE_REF, "GPSDestLatitudeRef"},
455
+ {ExifInterface.TAG_GPS_DEST_LONGITUDE, "GPSDestLongitude"},
456
+ {ExifInterface.TAG_GPS_DEST_LONGITUDE_REF, "GPSDestLongitudeRef"},
457
+ {ExifInterface.TAG_GPS_DIFFERENTIAL, "GPSDifferential"},
458
+ {ExifInterface.TAG_GPS_DOP, "GPSDOP"},
459
+ {ExifInterface.TAG_GPS_IMG_DIRECTION, "GPSImgDirection"},
460
+ {ExifInterface.TAG_GPS_IMG_DIRECTION_REF, "GPSImgDirectionRef"},
461
+ {ExifInterface.TAG_GPS_LATITUDE, "GPSLatitude"},
462
+ {ExifInterface.TAG_GPS_LATITUDE_REF, "GPSLatitudeRef"},
463
+ {ExifInterface.TAG_GPS_LONGITUDE, "GPSLongitude"},
464
+ {ExifInterface.TAG_GPS_LONGITUDE_REF, "GPSLongitudeRef"},
465
+ {ExifInterface.TAG_GPS_MAP_DATUM, "GPSMapDatum"},
466
+ {ExifInterface.TAG_GPS_MEASURE_MODE, "GPSMeasureMode"},
467
+ {ExifInterface.TAG_GPS_PROCESSING_METHOD, "GPSProcessingMethod"},
468
+ {ExifInterface.TAG_GPS_SATELLITES, "GPSSatellites"},
469
+ {ExifInterface.TAG_GPS_SPEED, "GPSSpeed"},
470
+ {ExifInterface.TAG_GPS_SPEED_REF, "GPSSpeedRef"},
471
+ {ExifInterface.TAG_GPS_STATUS, "GPSStatus"},
472
+ {ExifInterface.TAG_GPS_TIMESTAMP, "GPSTimeStamp"},
473
+ {ExifInterface.TAG_GPS_TRACK, "GPSTrack"},
474
+ {ExifInterface.TAG_GPS_TRACK_REF, "GPSTrackRef"},
475
+ {ExifInterface.TAG_GPS_VERSION_ID, "GPSVersionID"},
476
+ {ExifInterface.TAG_IMAGE_DESCRIPTION, "ImageDescription"},
477
+ {ExifInterface.TAG_IMAGE_LENGTH, "ImageLength"},
478
+ {ExifInterface.TAG_IMAGE_UNIQUE_ID, "ImageUniqueID"},
479
+ {ExifInterface.TAG_IMAGE_WIDTH, "ImageWidth"},
480
+ {ExifInterface.TAG_INTEROPERABILITY_INDEX, "InteroperabilityIndex"},
481
+ {ExifInterface.TAG_ISO_SPEED, "ISOSpeed"},
482
+ {ExifInterface.TAG_ISO_SPEED_LATITUDE_YYY, "ISOSpeedLatitudeyyy"},
483
+ {ExifInterface.TAG_ISO_SPEED_LATITUDE_ZZZ, "ISOSpeedLatitudezzz"},
484
+ {ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT, "JPEGInterchangeFormat"},
485
+ {ExifInterface.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, "JPEGInterchangeFormatLength"},
486
+ {ExifInterface.TAG_LIGHT_SOURCE, "LightSource"},
487
+ {ExifInterface.TAG_MAKE, "Make"},
488
+ {ExifInterface.TAG_MAKER_NOTE, "MakerNote"},
489
+ {ExifInterface.TAG_MAX_APERTURE_VALUE, "MaxApertureValue"},
490
+ {ExifInterface.TAG_METERING_MODE, "MeteringMode"},
491
+ {ExifInterface.TAG_MODEL, "Model"},
492
+ {ExifInterface.TAG_NEW_SUBFILE_TYPE, "NewSubfileType"},
493
+ {ExifInterface.TAG_OECF, "OECF"},
494
+ {ExifInterface.TAG_OFFSET_TIME, "OffsetTime"},
495
+ {ExifInterface.TAG_OFFSET_TIME_DIGITIZED, "OffsetTimeDigitized"},
496
+ {ExifInterface.TAG_OFFSET_TIME_ORIGINAL, "OffsetTimeOriginal"},
497
+ {ExifInterface.TAG_ORF_ASPECT_FRAME, "ORFAspectFrame"},
498
+ {ExifInterface.TAG_ORF_PREVIEW_IMAGE_LENGTH, "ORFPreviewImageLength"},
499
+ {ExifInterface.TAG_ORF_PREVIEW_IMAGE_START, "ORFPreviewImageStart"},
500
+ {ExifInterface.TAG_ORF_THUMBNAIL_IMAGE, "ORFThumbnailImage"},
501
+ {ExifInterface.TAG_ORIENTATION, "Orientation"},
502
+ {ExifInterface.TAG_PHOTOMETRIC_INTERPRETATION, "PhotometricInterpretation"},
503
+ {ExifInterface.TAG_PIXEL_X_DIMENSION, "PixelXDimension"},
504
+ {ExifInterface.TAG_PIXEL_Y_DIMENSION, "PixelYDimension"},
505
+ {ExifInterface.TAG_PLANAR_CONFIGURATION, "PlanarConfiguration"},
506
+ {ExifInterface.TAG_PRIMARY_CHROMATICITIES, "PrimaryChromaticities"},
507
+ {ExifInterface.TAG_RECOMMENDED_EXPOSURE_INDEX, "RecommendedExposureIndex"},
508
+ {ExifInterface.TAG_REFERENCE_BLACK_WHITE, "ReferenceBlackWhite"},
509
+ {ExifInterface.TAG_RELATED_SOUND_FILE, "RelatedSoundFile"},
510
+ {ExifInterface.TAG_RESOLUTION_UNIT, "ResolutionUnit"},
511
+ {ExifInterface.TAG_ROWS_PER_STRIP, "RowsPerStrip"},
512
+ {ExifInterface.TAG_RW2_ISO, "RW2ISO"},
513
+ {ExifInterface.TAG_RW2_JPG_FROM_RAW, "RW2JpgFromRaw"},
514
+ {ExifInterface.TAG_RW2_SENSOR_BOTTOM_BORDER, "RW2SensorBottomBorder"},
515
+ {ExifInterface.TAG_RW2_SENSOR_LEFT_BORDER, "RW2SensorLeftBorder"},
516
+ {ExifInterface.TAG_RW2_SENSOR_RIGHT_BORDER, "RW2SensorRightBorder"},
517
+ {ExifInterface.TAG_RW2_SENSOR_TOP_BORDER, "RW2SensorTopBorder"},
518
+ {ExifInterface.TAG_SAMPLES_PER_PIXEL, "SamplesPerPixel"},
519
+ {ExifInterface.TAG_SATURATION, "Saturation"},
520
+ {ExifInterface.TAG_SCENE_CAPTURE_TYPE, "SceneCaptureType"},
521
+ {ExifInterface.TAG_SCENE_TYPE, "SceneType"},
522
+ {ExifInterface.TAG_SENSING_METHOD, "SensingMethod"},
523
+ {ExifInterface.TAG_SENSITIVITY_TYPE, "SensitivityType"},
524
+ {ExifInterface.TAG_SHARPNESS, "Sharpness"},
525
+ {ExifInterface.TAG_SHUTTER_SPEED_VALUE, "ShutterSpeedValue"},
526
+ {ExifInterface.TAG_SOFTWARE, "Software"},
527
+ {ExifInterface.TAG_SPATIAL_FREQUENCY_RESPONSE, "SpatialFrequencyResponse"},
528
+ {ExifInterface.TAG_SPECTRAL_SENSITIVITY, "SpectralSensitivity"},
529
+ {ExifInterface.TAG_STANDARD_OUTPUT_SENSITIVITY, "StandardOutputSensitivity"},
530
+ {ExifInterface.TAG_STRIP_BYTE_COUNTS, "StripByteCounts"},
531
+ {ExifInterface.TAG_STRIP_OFFSETS, "StripOffsets"},
532
+ {ExifInterface.TAG_SUBFILE_TYPE, "SubfileType"},
533
+ {ExifInterface.TAG_SUBJECT_AREA, "SubjectArea"},
534
+ {ExifInterface.TAG_SUBJECT_DISTANCE, "SubjectDistance"},
535
+ {ExifInterface.TAG_SUBJECT_DISTANCE_RANGE, "SubjectDistanceRange"},
536
+ {ExifInterface.TAG_SUBJECT_LOCATION, "SubjectLocation"},
537
+ {ExifInterface.TAG_SUBSEC_TIME, "SubSecTime"},
538
+ {ExifInterface.TAG_SUBSEC_TIME_DIGITIZED, "SubSecTimeDigitized"},
539
+ {ExifInterface.TAG_SUBSEC_TIME_ORIGINAL, "SubSecTimeOriginal"},
540
+ {ExifInterface.TAG_THUMBNAIL_IMAGE_LENGTH, "ThumbnailImageLength"},
541
+ {ExifInterface.TAG_THUMBNAIL_IMAGE_WIDTH, "ThumbnailImageWidth"},
542
+ {ExifInterface.TAG_TRANSFER_FUNCTION, "TransferFunction"},
543
+ {ExifInterface.TAG_USER_COMMENT, "UserComment"},
544
+ {ExifInterface.TAG_WHITE_BALANCE, "WhiteBalance"},
545
+ {ExifInterface.TAG_WHITE_POINT, "WhitePoint"},
546
+ {ExifInterface.TAG_X_RESOLUTION, "XResolution"},
547
+ {ExifInterface.TAG_Y_CB_CR_COEFFICIENTS, "YCbCrCoefficients"},
548
+ {ExifInterface.TAG_Y_CB_CR_POSITIONING, "YCbCrPositioning"},
549
+ {ExifInterface.TAG_Y_CB_CR_SUB_SAMPLING, "YCbCrSubSampling"},
550
+ {ExifInterface.TAG_Y_RESOLUTION, "YResolution"}
551
+ };
552
+
368
553
  public void captureSample(int quality) {
369
554
  Log.d(TAG, "captureSample: Starting sample capture with quality: " + quality);
370
555
 
@@ -498,11 +683,10 @@ public class CameraXView implements LifecycleOwner {
498
683
  }
499
684
  }
500
685
 
501
- public static ZoomFactors getZoomFactorsStatic(Context context) {
686
+ public static ZoomFactors getZoomFactorsStatic() {
502
687
  try {
503
688
  // For static method, return default zoom factors
504
689
  // We can try to detect if ultra-wide is available by checking device list
505
- List<com.ahm.capacitor.camera.preview.model.CameraDevice> devices = getAvailableDevicesStatic(context);
506
690
 
507
691
  float minZoom = 1.0f;
508
692
  float maxZoom = 10.0f;
@@ -519,7 +703,7 @@ public class CameraXView implements LifecycleOwner {
519
703
 
520
704
  public ZoomFactors getZoomFactors() {
521
705
  if (camera == null) {
522
- return getZoomFactorsStatic(context);
706
+ return getZoomFactorsStatic();
523
707
  }
524
708
 
525
709
  try {
@@ -546,8 +730,6 @@ public class CameraXView implements LifecycleOwner {
546
730
 
547
731
  try {
548
732
  float currentZoom = Objects.requireNonNull(camera.getCameraInfo().getZoomState().getValue()).getZoomRatio();
549
- float minZoom = camera.getCameraInfo().getZoomState().getValue().getMinZoomRatio();
550
- float maxZoom = camera.getCameraInfo().getZoomState().getValue().getMaxZoomRatio();
551
733
 
552
734
  // Determine device type based on zoom capabilities
553
735
  String deviceType = "wideAngle";
@@ -594,46 +776,6 @@ public class CameraXView implements LifecycleOwner {
594
776
  }
595
777
  }
596
778
 
597
- private List<androidx.camera.core.CameraInfo> getAvailableCamerasForCurrentPosition() {
598
- if (cameraProvider == null) {
599
- Log.w(TAG, "getAvailableCamerasForCurrentPosition: cameraProvider is null");
600
- return Collections.emptyList();
601
- }
602
-
603
- List<androidx.camera.core.CameraInfo> allCameras = cameraProvider.getAvailableCameraInfos();
604
- List<androidx.camera.core.CameraInfo> sameFacingCameras = new ArrayList<>();
605
-
606
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Total cameras available: " + allCameras.size());
607
-
608
- // Determine current facing direction from the session config to avoid restricted API call
609
- boolean isCurrentBack = "back".equals(sessionConfig.getPosition());
610
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Looking for " + (isCurrentBack ? "back" : "front") + " cameras");
611
-
612
- for (int i = 0; i < allCameras.size(); i++) {
613
- androidx.camera.core.CameraInfo cameraInfo = allCameras.get(i);
614
- boolean isCameraBack = isBackCamera(cameraInfo);
615
- String cameraId = getCameraId(cameraInfo);
616
-
617
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Camera " + i + " - ID: " + cameraId + ", isBack: " + isCameraBack);
618
-
619
- try {
620
- float minZoom = Objects.requireNonNull(cameraInfo.getZoomState().getValue()).getMinZoomRatio();
621
- float maxZoom = cameraInfo.getZoomState().getValue().getMaxZoomRatio();
622
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Camera " + i + " zoom range: " + minZoom + "-" + maxZoom);
623
- } catch (Exception e) {
624
- Log.w(TAG, "getAvailableCamerasForCurrentPosition: Cannot get zoom info for camera " + i + ": " + e.getMessage());
625
- }
626
-
627
- if (isCameraBack == isCurrentBack) {
628
- sameFacingCameras.add(cameraInfo);
629
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Added camera " + i + " (" + cameraId + ") to same-facing list");
630
- }
631
- }
632
-
633
- Log.d(TAG, "getAvailableCamerasForCurrentPosition: Found " + sameFacingCameras.size() + " cameras for " + (isCurrentBack ? "back" : "front"));
634
- return sameFacingCameras;
635
- }
636
-
637
779
  public static List<Size> getSupportedPictureSizes(String facing) {
638
780
  List<Size> sizes = new ArrayList<>();
639
781
  try {
@@ -786,13 +928,13 @@ public class CameraXView implements LifecycleOwner {
786
928
  Log.d(TAG, "switchToDevice: Found matching CameraInfo for deviceId: " + deviceId);
787
929
  final CameraInfo finalTarget = targetCameraInfo;
788
930
 
789
- CameraSelector newSelector = new CameraSelector.Builder()
931
+ // This filter will receive a list of all cameras and must return the one we want.
932
+
933
+ currentCameraSelector = new CameraSelector.Builder()
790
934
  .addCameraFilter(cameras -> {
791
935
  // This filter will receive a list of all cameras and must return the one we want.
792
936
  return Collections.singletonList(finalTarget);
793
937
  }).build();
794
-
795
- currentCameraSelector = newSelector;
796
938
  currentDeviceId = deviceId;
797
939
  bindCameraUseCases(); // Rebind with the new, highly specific selector
798
940
  } else {
package/dist/docs.json CHANGED
@@ -57,7 +57,7 @@
57
57
  },
58
58
  {
59
59
  "name": "capture",
60
- "signature": "(options: CameraPreviewPictureOptions) => Promise<{ value: string; }>",
60
+ "signature": "(options: CameraPreviewPictureOptions) => Promise<{ value: string; exif: ExifData; }>",
61
61
  "parameters": [
62
62
  {
63
63
  "name": "options",
@@ -65,7 +65,7 @@
65
65
  "type": "CameraPreviewPictureOptions"
66
66
  }
67
67
  ],
68
- "returns": "Promise<{ value: string; }>",
68
+ "returns": "Promise<{ value: string; exif: ExifData; }>",
69
69
  "tags": [
70
70
  {
71
71
  "name": "param",
@@ -82,6 +82,7 @@
82
82
  ],
83
83
  "docs": "Captures a picture from the camera.",
84
84
  "complexTypes": [
85
+ "ExifData",
85
86
  "CameraPreviewPictureOptions"
86
87
  ],
87
88
  "slug": "capture"
@@ -688,7 +689,7 @@
688
689
  "name": "disableAudio",
689
690
  "tags": [
690
691
  {
691
- "text": "false",
692
+ "text": "true",
692
693
  "name": "default"
693
694
  }
694
695
  ],
@@ -774,6 +775,14 @@
774
775
  }
775
776
  ]
776
777
  },
778
+ {
779
+ "name": "ExifData",
780
+ "slug": "exifdata",
781
+ "docs": "Represents EXIF data extracted from an image.",
782
+ "tags": [],
783
+ "methods": [],
784
+ "properties": []
785
+ },
777
786
  {
778
787
  "name": "CameraPreviewPictureOptions",
779
788
  "slug": "camerapreviewpictureoptions",
@@ -820,6 +829,38 @@
820
829
  "PictureFormat"
821
830
  ],
822
831
  "type": "PictureFormat"
832
+ },
833
+ {
834
+ "name": "saveToGallery",
835
+ "tags": [
836
+ {
837
+ "text": "false",
838
+ "name": "default"
839
+ },
840
+ {
841
+ "text": "7.5.0",
842
+ "name": "since"
843
+ }
844
+ ],
845
+ "docs": "If true, the captured image will be saved to the user's gallery.",
846
+ "complexTypes": [],
847
+ "type": "boolean | undefined"
848
+ },
849
+ {
850
+ "name": "withExifLocation",
851
+ "tags": [
852
+ {
853
+ "text": "false",
854
+ "name": "default"
855
+ },
856
+ {
857
+ "text": "7.6.0",
858
+ "name": "since"
859
+ }
860
+ ],
861
+ "docs": "If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\nThis may prompt the user for location permissions.",
862
+ "complexTypes": [],
863
+ "type": "boolean | undefined"
823
864
  }
824
865
  ]
825
866
  },
@@ -140,7 +140,7 @@ export interface CameraPreviewOptions {
140
140
  enableHighResolution?: boolean;
141
141
  /**
142
142
  * If true, disables the audio stream, preventing audio permission requests.
143
- * @default false
143
+ * @default true
144
144
  */
145
145
  disableAudio?: boolean;
146
146
  /**
@@ -192,6 +192,23 @@ export interface CameraPreviewPictureOptions {
192
192
  * @default "jpeg"
193
193
  */
194
194
  format?: PictureFormat;
195
+ /**
196
+ * If true, the captured image will be saved to the user's gallery.
197
+ * @default false
198
+ * @since 7.5.0
199
+ */
200
+ saveToGallery?: boolean;
201
+ /**
202
+ * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.
203
+ * This may prompt the user for location permissions.
204
+ * @default false
205
+ * @since 7.6.0
206
+ */
207
+ withExifLocation?: boolean;
208
+ }
209
+ /** Represents EXIF data extracted from an image. */
210
+ export interface ExifData {
211
+ [key: string]: any;
195
212
  }
196
213
  export type PictureFormat = "jpeg" | "png";
197
214
  /** Defines a standard picture size with width and height. */
@@ -262,6 +279,7 @@ export interface CameraPreviewPlugin {
262
279
  */
263
280
  capture(options: CameraPreviewPictureOptions): Promise<{
264
281
  value: string;
282
+ exif: ExifData;
265
283
  }>;
266
284
  /**
267
285
  * Captures a single frame from the camera preview stream.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["export type CameraPosition = \"rear\" | \"front\";\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport enum DeviceType {\n ULTRA_WIDE = \"ultraWide\",\n WIDE_ANGLE = \"wideAngle\",\n TELEPHOTO = \"telephoto\",\n TRUE_DEPTH = \"trueDepth\",\n DUAL = \"dual\",\n DUAL_WIDE = \"dualWide\",\n TRIPLE = \"triple\",\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /** \n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /** \n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /** \n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /** \n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /** \n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /** \n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /** \n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /** \n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /** \n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /** \n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /** \n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /** \n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /** \n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /** \n * If true, enables high-resolution image capture.\n * @platform ios\n * @default false\n */\n enableHighResolution?: boolean;\n /** \n * If true, disables the audio stream, preventing audio permission requests.\n * @default false\n */\n disableAudio?: boolean;\n /** \n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /** \n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n /** \n * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: boolean;\n /** \n * If true, uses the video-optimized preset for the camera session.\n * @platform ios\n * @default false\n */\n enableVideoMode?: boolean;\n /** \n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** The desired height of the picture in pixels. If not provided, the device default is used. */\n height?: number;\n /** The desired width of the picture in pixels. If not provided, the device default is used. */\n width?: number;\n /** \n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /** \n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /** \n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"torch\";\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /** \n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<void>} A promise that resolves when the camera preview is started.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Stops the camera preview.\n *\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.4.0\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.4.0\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.4.0\n */\n getZoom(): Promise<{ \n min: number; \n max: number; \n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Sets the camera's zoom level.\n *\n * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.4.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.4.0\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the currently active camera device.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.4.0\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["export type CameraPosition = \"rear\" | \"front\";\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport enum DeviceType {\n ULTRA_WIDE = \"ultraWide\",\n WIDE_ANGLE = \"wideAngle\",\n TELEPHOTO = \"telephoto\",\n TRUE_DEPTH = \"trueDepth\",\n DUAL = \"dual\",\n DUAL_WIDE = \"dualWide\",\n TRIPLE = \"triple\",\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /** \n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /** \n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /** \n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /** \n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /** \n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /** \n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /** \n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /** \n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /** \n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /** \n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /** \n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /** \n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /** \n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /** \n * If true, enables high-resolution image capture.\n * @platform ios\n * @default false\n */\n enableHighResolution?: boolean;\n /** \n * If true, disables the audio stream, preventing audio permission requests.\n * @default true\n */\n disableAudio?: boolean;\n /** \n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /** \n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n /** \n * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: boolean;\n /** \n * If true, uses the video-optimized preset for the camera session.\n * @platform ios\n * @default false\n */\n enableVideoMode?: boolean;\n /** \n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** The desired height of the picture in pixels. If not provided, the device default is used. */\n height?: number;\n /** The desired width of the picture in pixels. If not provided, the device default is used. */\n width?: number;\n /** \n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /** \n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n /**\n * If true, the captured image will be saved to the user's gallery.\n * @default false\n * @since 7.5.0\n */\n saveToGallery?: boolean;\n /**\n * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\n * This may prompt the user for location permissions.\n * @default false\n * @since 7.6.0\n */\n withExifLocation?: boolean;\n}\n\n/** Represents EXIF data extracted from an image. */\nexport interface ExifData {\n [key: string]: any;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /** \n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"torch\";\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /** \n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<void>} A promise that resolves when the camera preview is started.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Stops the camera preview.\n *\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\n * @since 0.0.1\n */\n capture(\n options: CameraPreviewPictureOptions\n ): Promise<{ value: string; exif: ExifData }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.4.0\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.4.0\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.4.0\n */\n getZoom(): Promise<{ \n min: number; \n max: number; \n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Sets the camera's zoom level.\n *\n * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.4.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.4.0\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the currently active camera device.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.4.0\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n}\n"]}