|
| 1 | +import type { PermissionState } from '@capacitor/core'; |
| 2 | +export declare type CameraPermissionState = PermissionState | 'limited'; |
| 3 | +export declare type CameraPermissionType = 'camera' | 'photos'; |
| 4 | +export interface PermissionStatus { |
| 5 | + camera: CameraPermissionState; |
| 6 | + photos: CameraPermissionState; |
| 7 | +} |
| 8 | +export interface CameraPluginPermissions { |
| 9 | + permissions: CameraPermissionType[]; |
| 10 | +} |
| 11 | +export interface CameraPlugin { |
| 12 | + /** |
| 13 | + * Prompt the user to pick a photo from an album, or take a new photo |
| 14 | + * with the camera. |
| 15 | + * |
| 16 | + * @since 1.0.0 |
| 17 | + */ |
| 18 | + getPhoto(options: ImageOptions): Promise<Photo>; |
| 19 | + /** |
| 20 | + * Allows the user to pick multiplef pictures from the photo gallery. |
| 21 | + * |
| 22 | + * @since 1.2.0 |
| 23 | + */ |
| 24 | + pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>; |
| 25 | + /** |
| 26 | + * Allows the user to update their limited photo library selection. |
| 27 | + * Returns all the limited photos after the picker dismissal. |
| 28 | + * If instead the user gave full access to the photos it returns an empty array. |
| 29 | + * |
| 30 | + * @since 4.1.0 |
| 31 | + */ |
| 32 | + pickLimitedLibraryPhotos(): Promise<GalleryPhotos>; |
| 33 | + /** |
| 34 | + * Return an array of photos selected from the limited photo library. |
| 35 | + * |
| 36 | + * @since 4.1.0 |
| 37 | + */ |
| 38 | + getLimitedLibraryPhotos(): Promise<GalleryPhotos>; |
| 39 | + /** |
| 40 | + * Check camera and photo album permissions |
| 41 | + * |
| 42 | + * @since 1.0.0 |
| 43 | + */ |
| 44 | + checkPermissions(): Promise<PermissionStatus>; |
| 45 | + /** |
| 46 | + * Request camera and photo album permissions |
| 47 | + * |
| 48 | + * @since 1.0.0 |
| 49 | + */ |
| 50 | + requestPermissions(permissions?: CameraPluginPermissions): Promise<PermissionStatus>; |
| 51 | +} |
| 52 | +export interface ImageOptions { |
| 53 | + /** |
| 54 | + * The quality of image to return as JPEG, from 0-100 |
| 55 | + * Note: This option is only supported on Android and iOS |
| 56 | + * |
| 57 | + * @since 1.0.0 |
| 58 | + */ |
| 59 | + quality?: number; |
| 60 | + /** |
| 61 | + * Whether to allow the user to crop or make small edits (platform specific). |
| 62 | + * On iOS it's only supported for CameraSource.Camera, but not for CameraSource.Photos. |
| 63 | + * |
| 64 | + * @since 1.0.0 |
| 65 | + */ |
| 66 | + allowEditing?: boolean; |
| 67 | + /** |
| 68 | + * How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported |
| 69 | + * |
| 70 | + * @since 1.0.0 |
| 71 | + */ |
| 72 | + resultType: CameraResultType; |
| 73 | + /** |
| 74 | + * Whether to save the photo to the gallery. |
| 75 | + * If the photo was picked from the gallery, it will only be saved if edited. |
| 76 | + * @default: false |
| 77 | + * |
| 78 | + * @since 1.0.0 |
| 79 | + */ |
| 80 | + saveToGallery?: boolean; |
| 81 | + /** |
| 82 | + * The desired maximum width of the saved image. The aspect ratio is respected. |
| 83 | + * |
| 84 | + * @since 1.0.0 |
| 85 | + */ |
| 86 | + width?: number; |
| 87 | + /** |
| 88 | + * The desired maximum height of the saved image. The aspect ratio is respected. |
| 89 | + * |
| 90 | + * @since 1.0.0 |
| 91 | + */ |
| 92 | + height?: number; |
| 93 | + /** |
| 94 | + * Whether to automatically rotate the image "up" to correct for orientation |
| 95 | + * in portrait mode |
| 96 | + * @default: true |
| 97 | + * |
| 98 | + * @since 1.0.0 |
| 99 | + */ |
| 100 | + correctOrientation?: boolean; |
| 101 | + /** |
| 102 | + * The source to get the photo from. By default this prompts the user to select |
| 103 | + * either the photo album or take a photo. |
| 104 | + * @default: CameraSource.Prompt |
| 105 | + * |
| 106 | + * @since 1.0.0 |
| 107 | + */ |
| 108 | + source?: CameraSource; |
| 109 | + /** |
| 110 | + * iOS and Web only: The camera direction. |
| 111 | + * @default: CameraDirection.Rear |
| 112 | + * |
| 113 | + * @since 1.0.0 |
| 114 | + */ |
| 115 | + direction?: CameraDirection; |
| 116 | + /** |
| 117 | + * iOS only: The presentation style of the Camera. |
| 118 | + * @default: 'fullscreen' |
| 119 | + * |
| 120 | + * @since 1.0.0 |
| 121 | + */ |
| 122 | + presentationStyle?: 'fullscreen' | 'popover'; |
| 123 | + /** |
| 124 | + * Web only: Whether to use the PWA Element experience or file input. The |
| 125 | + * default is to use PWA Elements if installed and fall back to file input. |
| 126 | + * To always use file input, set this to `true`. |
| 127 | + * |
| 128 | + * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements |
| 129 | + * |
| 130 | + * @since 1.0.0 |
| 131 | + */ |
| 132 | + webUseInput?: boolean; |
| 133 | + /** |
| 134 | + * Text value to use when displaying the prompt. |
| 135 | + * @default: 'Photo' |
| 136 | + * |
| 137 | + * @since 1.0.0 |
| 138 | + * |
| 139 | + */ |
| 140 | + promptLabelHeader?: string; |
| 141 | + /** |
| 142 | + * Text value to use when displaying the prompt. |
| 143 | + * iOS only: The label of the 'cancel' button. |
| 144 | + * @default: 'Cancel' |
| 145 | + * |
| 146 | + * @since 1.0.0 |
| 147 | + */ |
| 148 | + promptLabelCancel?: string; |
| 149 | + /** |
| 150 | + * Text value to use when displaying the prompt. |
| 151 | + * The label of the button to select a saved image. |
| 152 | + * @default: 'From Photos' |
| 153 | + * |
| 154 | + * @since 1.0.0 |
| 155 | + */ |
| 156 | + promptLabelPhoto?: string; |
| 157 | + /** |
| 158 | + * Text value to use when displaying the prompt. |
| 159 | + * The label of the button to open the camera. |
| 160 | + * @default: 'Take Picture' |
| 161 | + * |
| 162 | + * @since 1.0.0 |
| 163 | + */ |
| 164 | + promptLabelPicture?: string; |
| 165 | +} |
| 166 | +export interface Photo { |
| 167 | + /** |
| 168 | + * The base64 encoded string representation of the image, if using CameraResultType.Base64. |
| 169 | + * |
| 170 | + * @since 1.0.0 |
| 171 | + */ |
| 172 | + base64String?: string; |
| 173 | + /** |
| 174 | + * The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl. |
| 175 | + * |
| 176 | + * Note: On web, the file format could change depending on the browser. |
| 177 | + * @since 1.0.0 |
| 178 | + */ |
| 179 | + dataUrl?: string; |
| 180 | + /** |
| 181 | + * If using CameraResultType.Uri, the path will contain a full, |
| 182 | + * platform-specific file URL that can be read later using the Filesystem API. |
| 183 | + * |
| 184 | + * @since 1.0.0 |
| 185 | + */ |
| 186 | + path?: string; |
| 187 | + /** |
| 188 | + * webPath returns a path that can be used to set the src attribute of an image for efficient |
| 189 | + * loading and rendering. |
| 190 | + * |
| 191 | + * @since 1.0.0 |
| 192 | + */ |
| 193 | + webPath?: string; |
| 194 | + /** |
| 195 | + * Exif data, if any, retrieved from the image |
| 196 | + * |
| 197 | + * @since 1.0.0 |
| 198 | + */ |
| 199 | + exif?: any; |
| 200 | + /** |
| 201 | + * The format of the image, ex: jpeg, png, gif. |
| 202 | + * |
| 203 | + * iOS and Android only support jpeg. |
| 204 | + * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser. |
| 205 | + * gif is only supported if `webUseInput` is set to `true` or if `source` is set to `Photos`. |
| 206 | + * |
| 207 | + * @since 1.0.0 |
| 208 | + */ |
| 209 | + format: string; |
| 210 | + /** |
| 211 | + * Whether if the image was saved to the gallery or not. |
| 212 | + * |
| 213 | + * On Android and iOS, saving to the gallery can fail if the user didn't |
| 214 | + * grant the required permissions. |
| 215 | + * On Web there is no gallery, so always returns false. |
| 216 | + * |
| 217 | + * @since 1.1.0 |
| 218 | + */ |
| 219 | + saved: boolean; |
| 220 | +} |
| 221 | +export interface GalleryPhotos { |
| 222 | + /** |
| 223 | + * Array of all the picked photos. |
| 224 | + * |
| 225 | + * @since 1.2.0 |
| 226 | + */ |
| 227 | + photos: GalleryPhoto[]; |
| 228 | +} |
| 229 | +export interface GalleryPhoto { |
| 230 | + /** |
| 231 | + * Full, platform-specific file URL that can be read later using the Filesystem API. |
| 232 | + * |
| 233 | + * @since 1.2.0 |
| 234 | + */ |
| 235 | + path?: string; |
| 236 | + /** |
| 237 | + * webPath returns a path that can be used to set the src attribute of an image for efficient |
| 238 | + * loading and rendering. |
| 239 | + * |
| 240 | + * @since 1.2.0 |
| 241 | + */ |
| 242 | + webPath: string; |
| 243 | + /** |
| 244 | + * Exif data, if any, retrieved from the image |
| 245 | + * |
| 246 | + * @since 1.2.0 |
| 247 | + */ |
| 248 | + exif?: any; |
| 249 | + /** |
| 250 | + * The format of the image, ex: jpeg, png, gif. |
| 251 | + * |
| 252 | + * iOS and Android only support jpeg. |
| 253 | + * Web supports jpeg, png and gif. |
| 254 | + * |
| 255 | + * @since 1.2.0 |
| 256 | + */ |
| 257 | + format: string; |
| 258 | +} |
| 259 | +export interface GalleryImageOptions { |
| 260 | + /** |
| 261 | + * The quality of image to return as JPEG, from 0-100 |
| 262 | + * Note: This option is only supported on Android and iOS. |
| 263 | + * |
| 264 | + * @since 1.2.0 |
| 265 | + */ |
| 266 | + quality?: number; |
| 267 | + /** |
| 268 | + * The desired maximum width of the saved image. The aspect ratio is respected. |
| 269 | + * |
| 270 | + * @since 1.2.0 |
| 271 | + */ |
| 272 | + width?: number; |
| 273 | + /** |
| 274 | + * The desired maximum height of the saved image. The aspect ratio is respected. |
| 275 | + * |
| 276 | + * @since 1.2.0 |
| 277 | + */ |
| 278 | + height?: number; |
| 279 | + /** |
| 280 | + * Whether to automatically rotate the image "up" to correct for orientation |
| 281 | + * in portrait mode |
| 282 | + * @default: true |
| 283 | + * |
| 284 | + * @since 1.2.0 |
| 285 | + */ |
| 286 | + correctOrientation?: boolean; |
| 287 | + /** |
| 288 | + * iOS only: The presentation style of the Camera. |
| 289 | + * @default: 'fullscreen' |
| 290 | + * |
| 291 | + * @since 1.2.0 |
| 292 | + */ |
| 293 | + presentationStyle?: 'fullscreen' | 'popover'; |
| 294 | + /** |
| 295 | + * Maximum number of pictures the user will be able to choose. |
| 296 | + * Note: This option is only supported on Android 13+ and iOS. |
| 297 | + * |
| 298 | + * @default 0 (unlimited) |
| 299 | + * |
| 300 | + * @since 1.2.0 |
| 301 | + */ |
| 302 | + limit?: number; |
| 303 | +} |
| 304 | +export declare enum CameraSource { |
| 305 | + /** |
| 306 | + * Prompts the user to select either the photo album or take a photo. |
| 307 | + */ |
| 308 | + Prompt = "PROMPT", |
| 309 | + /** |
| 310 | + * Take a new photo using the camera. |
| 311 | + */ |
| 312 | + Camera = "CAMERA", |
| 313 | + /** |
| 314 | + * Take multiple photos in a row using the camera. |
| 315 | + * Available on Android and iOS. |
| 316 | + */ |
| 317 | + CameraMulti = "CAMERA_MULTI", |
| 318 | + /** |
| 319 | + * Pick an existing photo from the gallery or photo album. |
| 320 | + */ |
| 321 | + Photos = "PHOTOS" |
| 322 | +} |
| 323 | +export declare enum CameraDirection { |
| 324 | + Rear = "REAR", |
| 325 | + Front = "FRONT" |
| 326 | +} |
| 327 | +export declare enum CameraResultType { |
| 328 | + Uri = "uri", |
| 329 | + Base64 = "base64", |
| 330 | + DataUrl = "dataUrl" |
| 331 | +} |
| 332 | +/** |
| 333 | + * @deprecated Use `Photo`. |
| 334 | + * @since 1.0.0 |
| 335 | + */ |
| 336 | +export declare type CameraPhoto = Photo; |
| 337 | +/** |
| 338 | + * @deprecated Use `ImageOptions`. |
| 339 | + * @since 1.0.0 |
| 340 | + */ |
| 341 | +export declare type CameraOptions = ImageOptions; |
0 commit comments