@capgo/camera-preview 7.4.0-beta.1 → 7.4.0-beta.11
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 +195 -31
- package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +3 -1
- package/android/src/main/AndroidManifest.xml +5 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +473 -88
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +2065 -704
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +95 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +55 -46
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +61 -52
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +152 -59
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +29 -23
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +24 -23
- package/dist/docs.json +235 -6
- package/dist/esm/definitions.d.ts +119 -3
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +47 -3
- package/dist/esm/web.js +297 -96
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +293 -96
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +293 -96
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreview/CameraController.swift +364 -218
- package/ios/Sources/CapgoCameraPreview/GridOverlayView.swift +65 -0
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +886 -242
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,52 @@ Then run
|
|
|
92
92
|
npx cap sync
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
## Optional Configuration
|
|
96
|
+
|
|
97
|
+
To use certain features of this plugin, you will need to add the following permissions/keys to your native project configurations.
|
|
98
|
+
|
|
99
|
+
### Android
|
|
100
|
+
|
|
101
|
+
In your `android/app/src/main/AndroidManifest.xml`:
|
|
102
|
+
|
|
103
|
+
- **Audio Recording** (`disableAudio: false`):
|
|
104
|
+
```xml
|
|
105
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Saving to Gallery** (`saveToGallery: true`):
|
|
109
|
+
```xml
|
|
110
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- **Location in EXIF Data** (`withExifLocation: true`):
|
|
114
|
+
```xml
|
|
115
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
116
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### iOS
|
|
120
|
+
|
|
121
|
+
In your `ios/App/App/Info.plist`, you must provide descriptions for the permissions your app requires. The keys are added automatically, but you need to provide the `string` values.
|
|
122
|
+
|
|
123
|
+
- **Audio Recording** (`disableAudio: false`):
|
|
124
|
+
```xml
|
|
125
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
126
|
+
<string>To record audio with videos</string>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **Saving to Gallery** (`saveToGallery: true`):
|
|
130
|
+
```xml
|
|
131
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
132
|
+
<string>To save photos to your gallery</string>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- **Location in EXIF Data** (`withExifLocation: true`):
|
|
136
|
+
```xml
|
|
137
|
+
<key>NSLocationWhenInUseUsageDescription</key>
|
|
138
|
+
<string>To add location data to your photos</string>
|
|
139
|
+
```
|
|
140
|
+
|
|
95
141
|
## Extra Android installation steps
|
|
96
142
|
|
|
97
143
|
**Important** `camera-preview` 3+ requires Gradle 7.
|
|
@@ -174,6 +220,10 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
|
|
|
174
220
|
* [`capture(...)`](#capture)
|
|
175
221
|
* [`captureSample(...)`](#capturesample)
|
|
176
222
|
* [`getSupportedFlashModes()`](#getsupportedflashmodes)
|
|
223
|
+
* [`setAspectRatio(...)`](#setaspectratio)
|
|
224
|
+
* [`getAspectRatio()`](#getaspectratio)
|
|
225
|
+
* [`setGridMode(...)`](#setgridmode)
|
|
226
|
+
* [`getGridMode()`](#getgridmode)
|
|
177
227
|
* [`getHorizontalFov()`](#gethorizontalfov)
|
|
178
228
|
* [`getSupportedPictureSizes()`](#getsupportedpicturesizes)
|
|
179
229
|
* [`setFlashMode(...)`](#setflashmode)
|
|
@@ -189,6 +239,8 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
|
|
|
189
239
|
* [`removeAllListeners()`](#removealllisteners)
|
|
190
240
|
* [`setDeviceId(...)`](#setdeviceid)
|
|
191
241
|
* [`getDeviceId()`](#getdeviceid)
|
|
242
|
+
* [`getPreviewSize()`](#getpreviewsize)
|
|
243
|
+
* [`setPreviewSize(...)`](#setpreviewsize)
|
|
192
244
|
* [Interfaces](#interfaces)
|
|
193
245
|
* [Type Aliases](#type-aliases)
|
|
194
246
|
* [Enums](#enums)
|
|
@@ -203,7 +255,7 @@ The main interface for the CameraPreview plugin.
|
|
|
203
255
|
### start(...)
|
|
204
256
|
|
|
205
257
|
```typescript
|
|
206
|
-
start(options: CameraPreviewOptions) => Promise<
|
|
258
|
+
start(options: CameraPreviewOptions) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
207
259
|
```
|
|
208
260
|
|
|
209
261
|
Starts the camera preview.
|
|
@@ -212,6 +264,8 @@ Starts the camera preview.
|
|
|
212
264
|
| ------------- | --------------------------------------------------------------------- | ------------------------------------------- |
|
|
213
265
|
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | - The configuration for the camera preview. |
|
|
214
266
|
|
|
267
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
268
|
+
|
|
215
269
|
**Since:** 0.0.1
|
|
216
270
|
|
|
217
271
|
--------------------
|
|
@@ -233,7 +287,7 @@ Stops the camera preview.
|
|
|
233
287
|
### capture(...)
|
|
234
288
|
|
|
235
289
|
```typescript
|
|
236
|
-
capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; }>
|
|
290
|
+
capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; exif: ExifData; }>
|
|
237
291
|
```
|
|
238
292
|
|
|
239
293
|
Captures a picture from the camera.
|
|
@@ -242,7 +296,7 @@ Captures a picture from the camera.
|
|
|
242
296
|
| ------------- | ----------------------------------------------------------------------------------- | ---------------------------------------- |
|
|
243
297
|
| **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> | - The options for capturing the picture. |
|
|
244
298
|
|
|
245
|
-
**Returns:** <code>Promise<{ value: string; }></code>
|
|
299
|
+
**Returns:** <code>Promise<{ value: string; exif: <a href="#exifdata">ExifData</a>; }></code>
|
|
246
300
|
|
|
247
301
|
**Since:** 0.0.1
|
|
248
302
|
|
|
@@ -283,6 +337,72 @@ Gets the flash modes supported by the active camera.
|
|
|
283
337
|
--------------------
|
|
284
338
|
|
|
285
339
|
|
|
340
|
+
### setAspectRatio(...)
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
setAspectRatio(options: { aspectRatio: "4:3" | "16:9"; x?: number; y?: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Set the aspect ratio of the camera preview.
|
|
347
|
+
|
|
348
|
+
| Param | Type | Description |
|
|
349
|
+
| ------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
350
|
+
| **`options`** | <code>{ aspectRatio: '4:3' \| '16:9'; x?: number; y?: number; }</code> | - The desired aspect ratio and optional position. - aspectRatio: The desired aspect ratio ('4:3' or '16:9') - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally. - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically. |
|
|
351
|
+
|
|
352
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
353
|
+
|
|
354
|
+
**Since:** 7.4.0
|
|
355
|
+
|
|
356
|
+
--------------------
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
### getAspectRatio()
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
getAspectRatio() => Promise<{ aspectRatio: "4:3" | "16:9"; }>
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Gets the current aspect ratio of the camera preview.
|
|
366
|
+
|
|
367
|
+
**Returns:** <code>Promise<{ aspectRatio: '4:3' | '16:9'; }></code>
|
|
368
|
+
|
|
369
|
+
**Since:** 7.4.0
|
|
370
|
+
|
|
371
|
+
--------------------
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
### setGridMode(...)
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
setGridMode(options: { gridMode: GridMode; }) => Promise<void>
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Sets the grid mode of the camera preview overlay.
|
|
381
|
+
|
|
382
|
+
| Param | Type | Description |
|
|
383
|
+
| ------------- | ------------------------------------------------------------ | -------------------------------------------------- |
|
|
384
|
+
| **`options`** | <code>{ gridMode: <a href="#gridmode">GridMode</a>; }</code> | - The desired grid mode ('none', '3x3', or '4x4'). |
|
|
385
|
+
|
|
386
|
+
**Since:** 8.0.0
|
|
387
|
+
|
|
388
|
+
--------------------
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
### getGridMode()
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
getGridMode() => Promise<{ gridMode: GridMode; }>
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Gets the current grid mode of the camera preview overlay.
|
|
398
|
+
|
|
399
|
+
**Returns:** <code>Promise<{ gridMode: <a href="#gridmode">GridMode</a>; }></code>
|
|
400
|
+
|
|
401
|
+
**Since:** 8.0.0
|
|
402
|
+
|
|
403
|
+
--------------------
|
|
404
|
+
|
|
405
|
+
|
|
286
406
|
### getHorizontalFov()
|
|
287
407
|
|
|
288
408
|
```typescript
|
|
@@ -515,6 +635,36 @@ Gets the ID of the currently active camera device.
|
|
|
515
635
|
--------------------
|
|
516
636
|
|
|
517
637
|
|
|
638
|
+
### getPreviewSize()
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
getPreviewSize() => Promise<{ x: number; y: number; width: number; height: number; }>
|
|
642
|
+
```
|
|
643
|
+
|
|
644
|
+
Gets the current preview size and position.
|
|
645
|
+
|
|
646
|
+
**Returns:** <code>Promise<{ x: number; y: number; width: number; height: number; }></code>
|
|
647
|
+
|
|
648
|
+
--------------------
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
### setPreviewSize(...)
|
|
652
|
+
|
|
653
|
+
```typescript
|
|
654
|
+
setPreviewSize(options: { x: number; y: number; width: number; height: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
Sets the preview size and position.
|
|
658
|
+
|
|
659
|
+
| Param | Type | Description |
|
|
660
|
+
| ------------- | --------------------------------------------------------------------- | -------------------------------- |
|
|
661
|
+
| **`options`** | <code>{ x: number; y: number; width: number; height: number; }</code> | The new position and dimensions. |
|
|
662
|
+
|
|
663
|
+
**Returns:** <code>Promise<{ width: number; height: number; x: number; y: number; }></code>
|
|
664
|
+
|
|
665
|
+
--------------------
|
|
666
|
+
|
|
667
|
+
|
|
518
668
|
### Interfaces
|
|
519
669
|
|
|
520
670
|
|
|
@@ -522,40 +672,49 @@ Gets the ID of the currently active camera device.
|
|
|
522
672
|
|
|
523
673
|
Defines the configuration options for starting the camera preview.
|
|
524
674
|
|
|
525
|
-
| Prop | Type
|
|
526
|
-
| ---------------------------------- |
|
|
527
|
-
| **`parent`** | <code>string</code>
|
|
528
|
-
| **`className`** | <code>string</code>
|
|
529
|
-
| **`width`** | <code>number</code>
|
|
530
|
-
| **`height`** | <code>number</code>
|
|
531
|
-
| **`x`** | <code>number</code>
|
|
532
|
-
| **`y`** | <code>number</code>
|
|
533
|
-
| **`
|
|
534
|
-
| **`
|
|
535
|
-
| **`
|
|
536
|
-
| **`
|
|
537
|
-
| **`
|
|
538
|
-
| **`
|
|
539
|
-
| **`
|
|
540
|
-
| **`
|
|
541
|
-
| **`
|
|
542
|
-
| **`
|
|
543
|
-
| **`
|
|
544
|
-
| **`
|
|
545
|
-
| **`
|
|
546
|
-
| **`
|
|
675
|
+
| Prop | Type | Description | Default | Since |
|
|
676
|
+
| ---------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
|
|
677
|
+
| **`parent`** | <code>string</code> | The parent element to attach the video preview to. | | |
|
|
678
|
+
| **`className`** | <code>string</code> | A CSS class name to add to the preview element. | | |
|
|
679
|
+
| **`width`** | <code>number</code> | The width of the preview in pixels. Defaults to the screen width. | | |
|
|
680
|
+
| **`height`** | <code>number</code> | The height of the preview in pixels. Defaults to the screen height. | | |
|
|
681
|
+
| **`x`** | <code>number</code> | The horizontal origin of the preview, in pixels. | | |
|
|
682
|
+
| **`y`** | <code>number</code> | The vertical origin of the preview, in pixels. | | |
|
|
683
|
+
| **`aspectRatio`** | <code>'4:3' \| '16:9'</code> | The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'. Cannot be set if width or height is provided, otherwise the call will be rejected. Use setPreviewSize to adjust size after starting. | | 2.0.0 |
|
|
684
|
+
| **`gridMode`** | <code><a href="#gridmode">GridMode</a></code> | The grid overlay to display on the camera preview. | <code>"none"</code> | 2.1.0 |
|
|
685
|
+
| **`includeSafeAreaInsets`** | <code>boolean</code> | Adjusts the y-position to account for safe areas (e.g., notches). | <code>false</code> | |
|
|
686
|
+
| **`toBack`** | <code>boolean</code> | If true, places the preview behind the webview. | <code>true</code> | |
|
|
687
|
+
| **`paddingBottom`** | <code>number</code> | Bottom padding for the preview, in pixels. | | |
|
|
688
|
+
| **`rotateWhenOrientationChanged`** | <code>boolean</code> | Whether to rotate the preview when the device orientation changes. | <code>true</code> | |
|
|
689
|
+
| **`position`** | <code>string</code> | The camera to use. | <code>"rear"</code> | |
|
|
690
|
+
| **`storeToFile`** | <code>boolean</code> | If true, saves the captured image to a file and returns the file path. If false, returns a base64 encoded string. | <code>false</code> | |
|
|
691
|
+
| **`disableExifHeaderStripping`** | <code>boolean</code> | If true, prevents the plugin from rotating the image based on EXIF data. | <code>false</code> | |
|
|
692
|
+
| **`enableHighResolution`** | <code>boolean</code> | If true, enables high-resolution image capture. | <code>false</code> | |
|
|
693
|
+
| **`disableAudio`** | <code>boolean</code> | If true, disables the audio stream, preventing audio permission requests. | <code>true</code> | |
|
|
694
|
+
| **`lockAndroidOrientation`** | <code>boolean</code> | If true, locks the device orientation while the camera is active. | <code>false</code> | |
|
|
695
|
+
| **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
|
|
696
|
+
| **`enableZoom`** | <code>boolean</code> | If true, enables pinch-to-zoom functionality on the preview. | <code>false</code> | |
|
|
697
|
+
| **`enableVideoMode`** | <code>boolean</code> | If true, uses the video-optimized preset for the camera session. | <code>false</code> | |
|
|
698
|
+
| **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
#### ExifData
|
|
702
|
+
|
|
703
|
+
Represents EXIF data extracted from an image.
|
|
547
704
|
|
|
548
705
|
|
|
549
706
|
#### CameraPreviewPictureOptions
|
|
550
707
|
|
|
551
708
|
Defines the options for capturing a picture.
|
|
552
709
|
|
|
553
|
-
| Prop
|
|
554
|
-
|
|
|
555
|
-
| **`height`**
|
|
556
|
-
| **`width`**
|
|
557
|
-
| **`quality`**
|
|
558
|
-
| **`format`**
|
|
710
|
+
| Prop | Type | Description | Default | Since |
|
|
711
|
+
| ---------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- | ----- |
|
|
712
|
+
| **`height`** | <code>number</code> | The desired height of the picture in pixels. If not provided, the device default is used. | | |
|
|
713
|
+
| **`width`** | <code>number</code> | The desired width of the picture in pixels. If not provided, the device default is used. | | |
|
|
714
|
+
| **`quality`** | <code>number</code> | The quality of the captured image, from 0 to 100. Does not apply to `png` format. | <code>85</code> | |
|
|
715
|
+
| **`format`** | <code><a href="#pictureformat">PictureFormat</a></code> | The format of the captured image. | <code>"jpeg"</code> | |
|
|
716
|
+
| **`saveToGallery`** | <code>boolean</code> | If true, the captured image will be saved to the user's gallery. | <code>false</code> | 7.5.0 |
|
|
717
|
+
| **`withExifLocation`** | <code>boolean</code> | If true, the plugin will attempt to add GPS location data to the image's EXIF metadata. This may prompt the user for location permissions. | <code>false</code> | 7.6.0 |
|
|
559
718
|
|
|
560
719
|
|
|
561
720
|
#### CameraSampleOptions
|
|
@@ -640,6 +799,11 @@ Represents the detailed information of the currently active lens.
|
|
|
640
799
|
### Type Aliases
|
|
641
800
|
|
|
642
801
|
|
|
802
|
+
#### GridMode
|
|
803
|
+
|
|
804
|
+
<code>"none" | "3x3" | "4x4"</code>
|
|
805
|
+
|
|
806
|
+
|
|
643
807
|
#### CameraPosition
|
|
644
808
|
|
|
645
809
|
<code>"rear" | "front"</code>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -49,7 +49,9 @@ dependencies {
|
|
|
49
49
|
implementation project(':capacitor-android')
|
|
50
50
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
51
51
|
implementation 'androidx.exifinterface:exifinterface:1.4.1'
|
|
52
|
-
|
|
52
|
+
implementation 'com.google.android.gms:play-services-location:21.3.0'
|
|
53
|
+
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.3.0'
|
|
54
|
+
|
|
53
55
|
// CameraX dependencies
|
|
54
56
|
def camerax_version = "1.5.0-beta01"
|
|
55
57
|
implementation "androidx.camera:camera-core:${camerax_version}"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
4
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
5
|
+
<uses-feature android:name="android.hardware.camera" />
|
|
6
|
+
<uses-feature android:name="android.hardware.camera.autofocus" />
|
|
4
7
|
</manifest>
|
|
5
|
-
|