react-native-image-picker
Version:
A React Native module that allows you to use native UI to select media from the device library or directly from the camera
73 lines (66 loc) • 1.6 kB
text/typescript
export type Callback = (response: ImagePickerResponse) => any;
export interface OptionsCommon {
mediaType: MediaType;
maxWidth?: number;
maxHeight?: number;
quality?: PhotoQuality;
videoQuality?: AndroidVideoOptions | iOSVideoOptions;
includeBase64?: boolean;
includeExtra?: boolean;
formatAsMp4?: boolean;
presentationStyle?:
| 'currentContext'
| 'fullScreen'
| 'pageSheet'
| 'formSheet'
| 'popover'
| 'overFullScreen'
| 'overCurrentContext';
assetRepresentationMode?: 'auto' | 'current' | 'compatible';
}
export interface ImageLibraryOptions extends OptionsCommon {
selectionLimit?: number;
restrictMimeTypes?: string[];
}
export interface CameraOptions extends OptionsCommon {
durationLimit?: number;
saveToPhotos?: boolean;
cameraType?: CameraType;
}
export interface Asset {
base64?: string;
uri?: string;
width?: number;
height?: number;
originalPath?: string;
fileSize?: number;
type?: string;
fileName?: string;
duration?: number;
bitrate?: number;
timestamp?: string;
id?: string;
}
export interface ImagePickerResponse {
didCancel?: boolean;
errorCode?: ErrorCode;
errorMessage?: string;
assets?: Asset[];
}
export type PhotoQuality =
| 0
| 0.1
| 0.2
| 0.3
| 0.4
| 0.5
| 0.6
| 0.7
| 0.8
| 0.9
| 1;
export type CameraType = 'back' | 'front';
export type MediaType = 'photo' | 'video' | 'mixed';
export type AndroidVideoOptions = 'low' | 'high';
export type iOSVideoOptions = 'low' | 'medium' | 'high';
export type ErrorCode = 'camera_unavailable' | 'permission' | 'others';