1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | export interface CameraOptions {
|
3 | /** Picture quality in range 0-100. Default is 50 */
|
4 | quality?: number;
|
5 | /**
|
6 | * Choose the format of the return value.
|
7 | * Defined in Camera.DestinationType. Default is FILE_URI.
|
8 | * DATA_URL : 0, Return image as base64-encoded string (DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible),
|
9 | * FILE_URI : 1, Return image file URI,
|
10 | * NATIVE_URI : 2 Return image native URI
|
11 | * (e.g., assets-library:// on iOS or content:// on Android)
|
12 | */
|
13 | destinationType?: number;
|
14 | /**
|
15 | * Set the source of the picture.
|
16 | * Defined in Camera.PictureSourceType. Default is CAMERA.
|
17 | * PHOTOLIBRARY : 0,
|
18 | * CAMERA : 1,
|
19 | * SAVEDPHOTOALBUM : 2
|
20 | */
|
21 | sourceType?: number;
|
22 | /** Allow simple editing of image before selection. */
|
23 | allowEdit?: boolean;
|
24 | /**
|
25 | * Choose the returned image file's encoding.
|
26 | * Defined in Camera.EncodingType. Default is JPEG
|
27 | * JPEG : 0 Return JPEG encoded image
|
28 | * PNG : 1 Return PNG encoded image
|
29 | */
|
30 | encodingType?: number;
|
31 | /**
|
32 | * Width in pixels to scale image. Must be used with targetHeight.
|
33 | * Aspect ratio remains constant.
|
34 | */
|
35 | targetWidth?: number;
|
36 | /**
|
37 | * Height in pixels to scale image. Must be used with targetWidth.
|
38 | * Aspect ratio remains constant.
|
39 | */
|
40 | targetHeight?: number;
|
41 | /**
|
42 | * Set the type of media to select from. Only works when PictureSourceType
|
43 | * is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in Camera.MediaType
|
44 | * PICTURE: 0 allow selection of still pictures only. DEFAULT.
|
45 | * Will return format specified via DestinationType
|
46 | * VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
|
47 | * ALLMEDIA : 2 allow selection from all media types
|
48 | */
|
49 | mediaType?: number;
|
50 | /** Rotate the image to correct for the orientation of the device during capture. */
|
51 | correctOrientation?: boolean;
|
52 | /** Save the image to the photo album on the device after capture. */
|
53 | saveToPhotoAlbum?: boolean;
|
54 | /**
|
55 | * Choose the camera to use (front- or back-facing).
|
56 | * Defined in Camera.Direction. Default is BACK.
|
57 | * BACK: 0
|
58 | * FRONT: 1
|
59 | */
|
60 | cameraDirection?: number;
|
61 | /** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
|
62 | popoverOptions?: CameraPopoverOptions;
|
63 | }
|
64 | /**
|
65 | * iOS-only parameters that specify the anchor element location and arrow direction
|
66 | * of the popover when selecting images from an iPad's library or album.
|
67 | */
|
68 | export interface CameraPopoverOptions {
|
69 | x: number;
|
70 | y: number;
|
71 | width: number;
|
72 | height: number;
|
73 | /**
|
74 | * Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
|
75 | * Matches iOS UIPopoverArrowDirection constants.
|
76 | * ARROW_UP : 1,
|
77 | * ARROW_DOWN : 2,
|
78 | * ARROW_LEFT : 4,
|
79 | * ARROW_RIGHT : 8,
|
80 | * ARROW_ANY : 15
|
81 | */
|
82 | arrowDir: number;
|
83 | }
|
84 | export declare enum DestinationType {
|
85 | DATA_URL = 0,
|
86 | FILE_URL = 1,
|
87 | NATIVE_URI = 2
|
88 | }
|
89 | export declare enum EncodingType {
|
90 | JPEG = 0,
|
91 | PNG = 1
|
92 | }
|
93 | export declare enum MediaType {
|
94 | PICTURE = 0,
|
95 | VIDEO = 1,
|
96 | ALLMEDIA = 2
|
97 | }
|
98 | export declare enum PictureSourceType {
|
99 | PHOTOLIBRARY = 0,
|
100 | CAMERA = 1,
|
101 | SAVEDPHOTOALBUM = 2
|
102 | }
|
103 | export declare enum PopoverArrowDirection {
|
104 | ARROW_UP = 1,
|
105 | ARROW_DOWN = 2,
|
106 | ARROW_LEFT = 3,
|
107 | ARROW_RIGHT = 4,
|
108 | ARROW_ANY = 5
|
109 | }
|
110 | export declare enum Direction {
|
111 | BACK = 0,
|
112 | FRONT = 1
|
113 | }
|
114 | /**
|
115 | * @name Camera
|
116 | * @premier camera
|
117 | * @description
|
118 | * Take a photo or capture video.
|
119 | *
|
120 | * Requires the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
|
121 | *
|
122 | * [Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add
|
123 | * ```xml
|
124 | * <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
|
125 | * <string>You can take photos</string>
|
126 | * </config-file>
|
127 | * ```
|
128 | * inside of the <platform name='ios> section
|
129 | *
|
130 | * @usage
|
131 | * ```typescript
|
132 | * import { Camera, CameraOptions } from '@ionic-native/camera/ngx';
|
133 | *
|
134 | * constructor(private camera: Camera) { }
|
135 | *
|
136 | * ...
|
137 | *
|
138 | *
|
139 | * const options: CameraOptions = {
|
140 | * quality: 100,
|
141 | * destinationType: this.camera.DestinationType.FILE_URI,
|
142 | * encodingType: this.camera.EncodingType.JPEG,
|
143 | * mediaType: this.camera.MediaType.PICTURE
|
144 | * }
|
145 | *
|
146 | * this.camera.getPicture(options).then((imageData) => {
|
147 | * // imageData is either a base64 encoded string or a file URI
|
148 | * // If it's base64 (DATA_URL):
|
149 | * let base64Image = 'data:image/jpeg;base64,' + imageData;
|
150 | * }, (err) => {
|
151 | * // Handle error
|
152 | * });
|
153 | * ```
|
154 | * @interfaces
|
155 | * CameraOptions
|
156 | * CameraPopoverOptions
|
157 | */
|
158 | export declare class CameraOriginal extends IonicNativePlugin {
|
159 | /**
|
160 | * Constant for possible destination types
|
161 | */
|
162 | DestinationType: {
|
163 | /** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */
|
164 | DATA_URL: number;
|
165 | /** Return file uri (content://media/external/images/media/2 for Android) */
|
166 | FILE_URI: number;
|
167 | /** Return native uri (eg. asset-library://... for iOS) */
|
168 | NATIVE_URI: number;
|
169 | };
|
170 | /**
|
171 | * Convenience constant
|
172 | */
|
173 | EncodingType: {
|
174 | /** Return JPEG encoded image */
|
175 | JPEG: number;
|
176 | /** Return PNG encoded image */
|
177 | PNG: number;
|
178 | };
|
179 | /**
|
180 | * Convenience constant
|
181 | */
|
182 | MediaType: {
|
183 | /** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
|
184 | PICTURE: number;
|
185 | /** Allow selection of video only, ONLY RETURNS URL */
|
186 | VIDEO: number;
|
187 | /** Allow selection from all media types */
|
188 | ALLMEDIA: number;
|
189 | };
|
190 | /**
|
191 | * Convenience constant
|
192 | */
|
193 | PictureSourceType: {
|
194 | /** Choose image from picture library (same as PHOTOLIBRARY for Android) */
|
195 | PHOTOLIBRARY: number;
|
196 | /** Take picture from camera */
|
197 | CAMERA: number;
|
198 | /** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */
|
199 | SAVEDPHOTOALBUM: number;
|
200 | };
|
201 | /**
|
202 | * Convenience constant
|
203 | */
|
204 | PopoverArrowDirection: {
|
205 | ARROW_UP: number;
|
206 | ARROW_DOWN: number;
|
207 | ARROW_LEFT: number;
|
208 | ARROW_RIGHT: number;
|
209 | ARROW_ANY: number;
|
210 | };
|
211 | /**
|
212 | * Convenience constant
|
213 | */
|
214 | Direction: {
|
215 | /** Use the back-facing camera */
|
216 | BACK: number;
|
217 | /** Use the front-facing camera */
|
218 | FRONT: number;
|
219 | };
|
220 | /**
|
221 | * Take a picture or video, or load one from the library.
|
222 | * @param {CameraOptions} [options] Options that you want to pass to the camera. Encoding type, quality, etc. Platform-specific quirks are described in the [Cordova plugin docs](https://github.com/apache/cordova-plugin-camera#cameraoptions-errata-).
|
223 | * @returns {Promise<any>} Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
|
224 | */
|
225 | getPicture(options?: CameraOptions): Promise<any>;
|
226 | /**
|
227 | * Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
|
228 | * Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
|
229 | * @returns {Promise<any>}
|
230 | */
|
231 | cleanup(): Promise<any>;
|
232 | }
|
233 |
|
234 | export declare const Camera: CameraOriginal; |
\ | No newline at end of file |