@deva-community/capacitor-camera-pro v1.0.0
capacitor-camera-pro
The CameraPro API provides the ability to take a photo or video with the camera or choose an existing one from the photo album.
Based on @capacitor/camera and inpired from:
https://github.com/apache/cordova-plugin-media-capture https://github.com/danielsogl/cordova-plugin-video-capture-plus
Install
npm install @deva-community/capacitor-camera-pro
npx cap sync
API
getPhoto(...)
getVideo(...)
pickImages(...)
checkPermissions()
requestPermissions(...)
- Interfaces
- Type Aliases
- Enums
getPhoto(...)
getPhoto(options: ImageOptions) => Promise<Photo>
Prompt the user to pick a photo from an album, or take a new photo with the camera.
Param | Type |
---|---|
options | ImageOptions |
Returns: Promise<Photo>
Since: 1.0.0
getVideo(...)
getVideo(options: VideoOptions) => Promise<Video>
Prompt the user to pick a photo from an album, or take a new photo with the camera.
Param | Type |
---|---|
options | VideoOptions |
Returns: Promise<Video>
Since: 1.0.0
pickImages(...)
pickImages(options: GalleryImageOptions) => Promise<GalleryPhotos>
Allows the user to pick multiple pictures from the photo gallery. On iOS 13 and older it only allows to pick one picture.
Param | Type |
---|---|
options | GalleryImageOptions |
Returns: Promise<GalleryPhotos>
Since: 1.2.0
checkPermissions()
checkPermissions() => Promise<PermissionStatus>
Check camera and photo album permissions
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions(...)
requestPermissions(permissions?: CameraProPluginPermissions | undefined) => Promise<PermissionStatus>
Request camera and photo album permissions
Param | Type |
---|---|
permissions | CameraProPluginPermissions |
Returns: Promise<PermissionStatus>
Since: 1.0.0
Interfaces
Photo
Prop | Type | Description | Since |
---|---|---|---|
base64String | string | The base64 encoded string representation of the image, if using CameraResultType.Base64. | 1.0.0 |
dataUrl | string | The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl. | 1.0.0 |
path | string | If using CameraResultType.Uri, the path will contain a full, platform-specific file URL that can be read later using the Filsystem API. | 1.0.0 |
webPath | string | webPath returns a path that can be used to set the src attribute of an image for efficient loading and rendering. | 1.0.0 |
exif | any | Exif data, if any, retrieved from the image | 1.0.0 |
format | string | The format of the image, ex: jpeg, png, gif. iOS and Android only support jpeg. Web supports jpeg and png. gif is only supported if using file input. | 1.0.0 |
saved | boolean | Whether if the image was saved to the gallery or not. On Android and iOS, saving to the gallery can fail if the user didn't grant the required permissions. On Web there is no gallery, so always returns false. | 1.1.0 |
ImageOptions
Prop | Type | Description | Default | Since |
---|---|---|---|---|
quality | number | The quality of image to return as JPEG, from 0-100 | 1.0.0 | |
allowEditing | boolean | Whether to allow the user to crop or make small edits (platform specific). On iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos. | 1.0.0 | |
resultType | CameraResultType | How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported | 1.0.0 | |
saveToGallery | boolean | Whether to save the photo to the gallery. If the photo was picked from the gallery, it will only be saved if edited. | : false | 1.0.0 |
width | number | The width of the saved image | 1.0.0 | |
height | number | The height of the saved image | 1.0.0 | |
preserveAspectRatio | boolean | This setting has no effect. Picture resizing always preserve aspect ratio. | 1.0.0 | |
correctOrientation | boolean | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | : true | 1.0.0 |
source | CameraSource | The source to get the photo from. By default this prompts the user to select either the photo album or take a photo. | : CameraSource.Prompt | 1.0.0 |
direction | CameraDirection | iOS and Web only: The camera direction. | : CameraDirection.Rear | 1.0.0 |
presentationStyle | 'fullscreen' | 'popover' | iOS only: The presentation style of the Camera. | : 'fullscreen' | 1.0.0 |
webUseInput | boolean | Web only: Whether to use the PWA Element experience or file input. The default is to use PWA Elements if installed and fall back to file input. To always use file input, set this to true . Learn more about PWA Elements: https://capacitorjs.com/docs/pwa-elements | 1.0.0 | |
promptLabelHeader | string | Text value to use when displaying the prompt. | : 'Photo' | 1.0.0 |
promptLabelCancel | string | Text value to use when displaying the prompt. iOS only: The label of the 'cancel' button. | : 'Cancel' | 1.0.0 |
promptLabelPhoto | string | Text value to use when displaying the prompt. The label of the button to select a saved image. | : 'From Photos' | 1.0.0 |
promptLabelPicture | string | Text value to use when displaying the prompt. The label of the button to open the camera. | : 'Take Picture' | 1.0.0 |
Video
Prop | Type | Description | Since |
---|---|---|---|
path | string | If using CameraResultType.Uri, the path will contain a full, platform-specific file URL that can be read later using the Filsystem API. | 1.0.0 |
webPath | string | webPath returns a path that can be used to set the src attribute of an video for efficient loading and rendering. | 1.2.0 |
format | string | The format of the video, ex: mp4, 3gp. | 1.0.0 |
saved | boolean | Whether if the video was saved to the gallery or not. On Android and iOS, saving to the gallery can fail if the user didn't grant the required permissions. On Web there is no gallery, so always returns false. | 1.1.0 |
VideoOptions
Prop | Type | Description | Default | Since |
---|---|---|---|---|
saveToGallery | boolean | Whether to save the video to the gallery. If the video was picked from the gallery, it will only be saved if edited. | : false | 1.0.0 |
duration | number | The maximum duration of the video in seconds. | 0 (unlimited) | 1.0.0 |
highquality | boolean | Set to true to override the default low quality setting | 1.0.0 | |
source | CameraVideoSource | The source to get the video from. By default this prompts the user to select either the library or take a video. | : CameraVideoSource.Prompt | 1.0.0 |
promptLabelHeader | string | Text value to use when displaying the prompt. | : 'Video' | 1.0.0 |
promptLabelCancel | string | Text value to use when displaying the prompt. iOS only: The label of the 'cancel' button. | : 'Cancel' | 1.0.0 |
promptLabelLibrary | string | Text value to use when displaying the prompt. The label of the button to select a saved image. | : 'From Library' | 1.0.0 |
promptLabelVideo | string | Text value to use when displaying the prompt. The label of the button to open the camera. | : 'Take Video' | 1.0.0 |
GalleryPhotos
Prop | Type | Description | Since |
---|---|---|---|
photos | GalleryPhoto[] | Array of all the picked photos. | 1.2.0 |
GalleryPhoto
Prop | Type | Description | Since |
---|---|---|---|
path | string | Full, platform-specific file URL that can be read later using the Filsystem API. | 1.2.0 |
webPath | string | webPath returns a path that can be used to set the src attribute of an image for efficient loading and rendering. | 1.2.0 |
exif | any | Exif data, if any, retrieved from the image | 1.2.0 |
format | string | The format of the image, ex: jpeg, png, gif. iOS and Android only support jpeg. Web supports jpeg, png and gif. | 1.2.0 |
GalleryImageOptions
Prop | Type | Description | Default | Since |
---|---|---|---|---|
quality | number | The quality of image to return as JPEG, from 0-100 | 1.2.0 | |
width | number | The width of the saved image | 1.2.0 | |
height | number | The height of the saved image | 1.2.0 | |
correctOrientation | boolean | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | : true | 1.2.0 |
presentationStyle | 'fullscreen' | 'popover' | iOS only: The presentation style of the Camera. | : 'fullscreen' | 1.2.0 |
limit | number | iOS only: Maximum number of pictures the user will be able to choose. | 0 (unlimited) | 1.2.0 |
PermissionStatus
Prop | Type |
---|---|
camera | CameraProPermissionState |
photos | CameraProPermissionState |
CameraProPluginPermissions
Prop | Type |
---|---|
permissions | CameraProPermissionType[] |
Type Aliases
CameraProPermissionState
PermissionState | 'limited'
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
CameraProPermissionType
'camera' | 'photos'
Enums
CameraResultType
Members | Value |
---|---|
Uri | 'uri' |
Base64 | 'base64' |
DataUrl | 'dataUrl' |
CameraSource
Members | Value | Description |
---|---|---|
Prompt | 'PROMPT' | Prompts the user to select either the photo album or take a photo. |
Camera | 'CAMERA' | Take a new photo using the camera. |
Photos | 'PHOTOS' | Pick an existing photo fron the gallery or photo album. |
CameraDirection
Members | Value |
---|---|
Rear | 'REAR' |
Front | 'FRONT' |
CameraVideoSource
Members | Value | Description |
---|---|---|
Prompt | 'PROMPT' | Prompts the user to select either the photo album or take a photo. |
Camera | 'CAMERA' | Take a new photo using the camera. |
Library | 'LIBRARY' | Pick an existing photo fron the gallery or photo album. |
3 years ago