시작하기
__CAPGO_KEEP_4__
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/camera-preview`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/camera-preview/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
__CAPGO_KEEP_11__
설치Capgo AI 도구에 다음 명령어를 사용하여 Capgo 기능을 추가할 수 있습니다.
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins다음 명령어를 사용하여 __CAPGO_KEEP_0__ 기능을 추가할 수 있습니다.
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/camera-preview` plugin in my project.만약 Manual Setup을 선호한다면, 다음 명령어를 실행하고 아래의 플랫폼별 지침을 따르세요.
bun add @capgo/camera-previewbunx cap syncimport
importimport { CameraPreview } from '@capgo/camera-preview';API 개요
API 개요 섹션start
시작카메라 프리뷰를 시작합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.start({} as CameraPreviewOptions);카메라 프리뷰를 중지합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.stop();capture
__CAPGO_KEEP_0__ 섹션사진을 찍습니다.
만약 storeToFile 설정된 값이 true 시연을 시작할 때 반환되는
value 디바이스의 절대 파일 경로 대신 base64 문자열이 아닌 것입니다. getBase64FromFilePath를 사용하여 파일 경로에서 base64 문자열을 가져옵니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.capture({} as CameraPreviewPictureOptions);captureSample
“captureSample”라는 제목의 섹션카메라 시연 스트림에서 단일 프레임을 캡처합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.captureSample({} as CameraSampleOptions);getSupportedFlashModes
“getSupportedFlashModes”라는 제목의 섹션활성 카메라에서 지원하는 플래시 모드 가져옵니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getSupportedFlashModes();setAspectRatio
“setAspectRatio”라는 제목의 섹션카메라 시연의 가로비율을 설정합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setAspectRatio({} as { aspectRatio: '4:3' | '16:9'; x?: number; y?: number });getAspectRatio
__CAPGO_KEEP_0____CAPGO_KEEP_1__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getAspectRatio();setGridMode
__CAPGO_KEEP_3____CAPGO_KEEP_4__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setGridMode({} as { gridMode: GridMode });getGridMode
__CAPGO_KEEP_6____CAPGO_KEEP_7__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getGridMode();checkPermissions
__CAPGO_KEEP_9____CAPGO_KEEP_10__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.checkPermissions();requestPermissions
requestPermissions카메라 (마이크 옵션) 권한을 요청합니다. 권한이 이미 허용되거나 거부된 경우, 현재 상태가 반환됩니다. showSettingsAlert 권한이 거부된 경우, 사용자에게 앱 설정으로 안내하는 플랫폼별 알림이 표시됩니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.requestPermissions();getHorizontalFov
getHorizontalFov활성 카메라의 수평 시야각을 가져옵니다. 일부 기기에서는 추정치가 될 수 있습니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getHorizontalFov();getSupportedPictureSizes
getSupportedPictureSizes모든 카메라의 지원하는 사진 크기를 가져옵니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getSupportedPictureSizes();setFlashMode
setFlashMode활성 카메라의 플래시 모드를 설정합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setFlashMode({} as { flashMode: CameraPreviewFlashMode | string });flip
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.flip();setOpacity
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setOpacity({} as CameraOpacityOptions);stopRecordVideo
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.stopRecordVideo();startRecordVideo
__CAPGO_KEEP_1____CAPGO_KEEP_5__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.startRecordVideo({} as CameraPreviewOptions);isRunning
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.isRunning();getAvailableDevices
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getAvailableDevices();getZoom
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getZoom();getZoomButtonValues
__CAPGO_KEEP_1____CAPGO_KEEP_5__
- iOS/Android: 초광각이 사용 가능하면 0.5를 포함하고, 광각이 사용 가능하면 1과 2를 포함하고, 망원경이 사용 가능하면 3을 포함합니다.
- Web: 지원되지 않음
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getZoomButtonValues();setZoom
setZoom카메라의 줌 레벨을 설정합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setZoom({} as { level: number; ramp?: boolean; autoFocus?: boolean });getFlashMode
getFlashMode현재 플래시 모드를 가져옵니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getFlashMode();setDeviceId
setDeviceId사용자 지정 카메라 ID를 사용하여 활성 카메라를-switch합니다. deviceId.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setDeviceId({} as { deviceId: string });getDeviceId
__CAPGO_KEEP_0____CAPGO_KEEP_1__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getDeviceId();getPreviewSize
__CAPGO_KEEP_3____CAPGO_KEEP_4__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getPreviewSize();setPreviewSize
__CAPGO_KEEP_6____CAPGO_KEEP_7__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setPreviewSize({} as { x?: number; y?: number; width: number; height: number });setFocus
__CAPGO_KEEP_9____CAPGO_KEEP_10__
__CAPGO_KEEP_11__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setFocus({} as { x: number; y: number });deleteFile
__CAPGO_KEEP_1____CAPGO_KEEP_2__ storeToFile__CAPGO_KEEP_3__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.deleteFile({} as { path: string });getSafeAreaInsets
__CAPGO_KEEP_5____CAPGO_KEEP_6__
__CAPGO_KEEP_7__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getSafeAreaInsets();getOrientation
__CAPGO_KEEP_9____CAPGO_KEEP_10__
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getOrientation();getExposureModes
Section titled “getExposureModes”활성 카메라에서 지원하는 노출 모드들을 반환합니다. 모드에는 ‘locked’, ‘auto’, ‘continuous’, ‘custom’가 포함될 수 있습니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getExposureModes();getExposureMode
Section titled “getExposureMode”현재 노출 모드를 반환합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getExposureMode();setExposureMode
Section titled “setExposureMode”노출 모드를 설정합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setExposureMode({} as { mode: ExposureMode });getExposureCompensationRange
Section titled “getExposureCompensationRange”노출 보상 (EV bias) 지원 범위를 반환합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getExposureCompensationRange();getExposureCompensation
Section titled “getExposureCompensation”현재 노출 보상 (EV bias)을 반환합니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.getExposureCompensation();setExposureCompensation
Section titled “setExposureCompensation”노출 보상 (EV bias)을 설정합니다. 값은 지정된 범위 내로 클램핑됩니다.
import { CameraPreview } from '@capgo/camera-preview';
await CameraPreview.setExposureCompensation({} as { value: number });Type Reference
Section titled “Type Reference”CameraPreviewOptions
Section titled “카메라 프리뷰 옵션”카메라 프리뷰를 시작할 때의 구성 옵션을 정의합니다.
export interface CameraPreviewOptions { /** * The parent element to attach the video preview to. * @platform web */ parent?: string; /** * A CSS class name to add to the preview element. * @platform web */ className?: string; /** * The width of the preview in pixels. Defaults to the screen width. * @platform android, ios, web */ width?: number; /** * The height of the preview in pixels. Defaults to the screen height. * @platform android, ios, web */ height?: number; /** * The horizontal origin of the preview, in pixels. * @platform android, ios */ x?: number; /** * The vertical origin of the preview, in pixels. * @platform android, ios */ y?: number; /** * 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. * * @since 2.0.0 */ aspectRatio?: '4:3' | '16:9'; /** * Controls how the camera preview fills the available space. * - 'contain': Fits the entire preview within the space, may show letterboxing (default). * - 'cover': Fills the entire space, may crop edges of the preview. * @default "contain" * @platform android, ios, web */ aspectMode?: 'cover' | 'contain'; /** * The grid overlay to display on the camera preview. * @default "none" * @since 2.1.0 */ gridMode?: GridMode; /** * Adjusts the y-position to account for safe areas (e.g., notches). * @platform ios * @default false */ includeSafeAreaInsets?: boolean; /** * If true, places the preview behind the webview. * @platform android * @default true */ toBack?: boolean; /** * Bottom padding for the preview, in pixels. * @platform android, ios */ paddingBottom?: number; /** * Whether to rotate the preview when the device orientation changes. * @platform ios * @default true */ rotateWhenOrientationChanged?: boolean; /** * The camera to use. * @default "rear" */ position?: CameraPosition | string; /** * If true, saves the captured image to a file and returns the file path. * If false, returns a base64 encoded string. * @default false */ storeToFile?: boolean; /** * If true, prevents the plugin from rotating the image based on EXIF data. * @platform android * @default false */ disableExifHeaderStripping?: boolean; /** * If true, disables the audio stream, preventing audio permission requests. * @default true */ disableAudio?: boolean; /** * If true, locks the device orientation while the camera is active. * @platform android * @default false */ lockAndroidOrientation?: boolean; /** * If true, allows the camera preview's opacity to be changed. * @platform android, web * @default false */ enableOpacity?: boolean;
/** * If true, disables the visual focus indicator when tapping to focus. * @platform android, ios * @default false */ disableFocusIndicator?: boolean; /** * The `deviceId` of the camera to use. If provided, `position` is ignored. * @platform ios */ deviceId?: string; /** * On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens. * Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior. * @default false * @platform android */ enablePhysicalDeviceSelection?: boolean; /** * The initial zoom level when starting the camera preview. * If the requested zoom level is not available, the native plugin will reject. * @default 1.0 * @platform android, ios * @since 2.2.0 */ initialZoomLevel?: number; /** * The vertical positioning of the camera preview. * @default "center" * @platform android, ios, web * @since 2.3.0 */ positioning?: CameraPositioning; /** * If true, enables video capture capabilities when the camera starts. * @default false * @platform android * @since 7.11.0 */ enableVideoMode?: boolean; /** * If true, forces the camera to start/restart even if it's already running or busy. * This will kill the current camera session and start a new one, ignoring all state checks. * @default false * @platform android, ios, web */ force?: boolean; /** * Sets the quality of video for recording. * Options: 'low', 'medium', 'high' * @note On Android requires 'enableVideoMode' to be true * @note Will affect the entire preview stream for iOS * @platform ios, android * @default "high" */ videoQuality?: 'low' | 'medium' | 'high';}CameraPreviewPictureOptions
Section titled “카메라 프리뷰 사진 옵션”__CAPGO_KEEP_0__
export interface CameraPreviewPictureOptions { /** * The maximum height of the picture in pixels. The image will be resized to fit within this height while maintaining aspect ratio. * If not specified the captured image will match the preview's visible area. */ height?: number; /** * The maximum width of the picture in pixels. The image will be resized to fit within this width while maintaining aspect ratio. * If not specified the captured image will match the preview's visible area. */ width?: number; /** * The quality of the captured image, from 0 to 100. * Does not apply to `.png` format. * @default 85 */ quality?: number; /** * The format of the captured image. * @default "jpeg" */ format?: PictureFormat; /** * If true, the captured image will be saved to the user's gallery. * @default false * @since 7.5.0 */ saveToGallery?: boolean; /** * 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. * @default false * @since 7.6.0 */ withExifLocation?: boolean; /** * If true, the plugin will embed a timestamp in the top-right corner of the image. * @default false * @since 7.17.0 */ embedTimestamp?: boolean; /** * If true, the plugin will embed the current location in the top-right corner of the image. * Requires `withExifLocation` to be enabled. * @default false * @since 7.18.0 */ embedLocation?: boolean; /** * Sets the priority for photo quality vs. capture speed. * - "speed": Prioritizes faster capture times, may reduce image quality. * - "balanced": Aims for a balance between quality and speed. * - "quality": Prioritizes image quality, may reduce capture speed. * See https://developer.apple.com/documentation/avfoundation/avcapturephotosettings/photoqualityprioritization for details. * * @since 7.21.0 * @platform ios * @default "speed" */ photoQualityPrioritization?: 'speed' | 'balanced' | 'quality';}ExifData
__CAPGO_KEEP_2____CAPGO_KEEP_3__
export interface ExifData { [key: string]: any;}CameraSampleOptions
__CAPGO_KEEP_2____CAPGO_KEEP_4__
export interface CameraSampleOptions { /** * The quality of the captured sample, from 0 to 100. * @default 85 */ quality?: number;}CameraPreviewFlashMode
__CAPGO_KEEP_5____CAPGO_KEEP_1__
export type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'torch';GridMode
__CAPGO_KEEP_6__export type GridMode = 'none' | '3x3' | '4x4';PermissionRequestOptions
__CAPGO_KEEP_1__export interface PermissionRequestOptions { disableAudio?: boolean; showSettingsAlert?: boolean; title?: string; message?: string; openSettingsButtonTitle?: string; cancelButtonTitle?: string;}CameraPermissionStatus
__CAPGO_KEEP_1__export interface CameraPermissionStatus { camera: PermissionState; microphone?: PermissionState;}SupportedPictureSizes
__CAPGO_KEEP_1____CAPGO_KEEP_2__
export interface SupportedPictureSizes { /** The camera direction ("front" or "rear"). */ facing: string; /** A list of supported picture sizes for this camera. */ supportedPictureSizes: PictureSize[];}CameraOpacityOptions
__CAPGO_KEEP_3____CAPGO_KEEP_0__
export interface CameraOpacityOptions { /** * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque). * @default 1.0 */ opacity?: number;}CameraDevice
__CAPGO_KEEP_4____CAPGO_KEEP_0__
export interface CameraDevice { /** A unique identifier for the camera device. */ deviceId: string; /** A human-readable name for the camera device. */ label: string; /** The physical position of the camera on the device. */ position: CameraPosition; /** A list of all available lenses for this camera device. */ lenses: CameraLens[]; /** The overall minimum zoom factor available across all lenses on this device. */ minZoom: number; /** The overall maximum zoom factor available across all lenses on this device. */ maxZoom: number; /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */ isLogical: boolean;}LensInfo
__CAPGO_KEEP_0____CAPGO_KEEP_0__
export interface LensInfo { /** The focal length of the active lens in millimeters. */ focalLength: number; /** The device type of the active lens. */ deviceType: DeviceType; /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */ baseZoomRatio: number; /** The current digital zoom factor applied on top of the base zoom. */ digitalZoom: number;}__CAPGO_KEEP_0__
__CAPGO_KEEP_0____CAPGO_KEEP_0__ src/definitions.tsAPI
__CAPGO_KEEP_0__
__CAPGO_KEEP_0____CAPGO_KEEP_0__ Getting Started native 미디어 및 인터페이스 동작을 계획하고 연결하기 위해 Using @capgo/camera-preview native 기능을 사용하기 위해 @capgo/camera-preview Using @capgo/capacitor-live-activities native 기능을 사용하기 위해 @capgo/capacitor-live-activities @capgo/capacitor-live-activities @capgo/capacitor-live-activities의 구현 세부 사항 Using @capgo/capacitor-video-player native 기능을 사용하기 위해 @capgo/capacitor-video-player, @capgo/capacitor-video-player @capgo/capacitor-video-player의 구현 세부 사항