capacitor-community / capacitor-community/camera-preview

How to properly obtain the image file using storeToFile: true

Open
#211 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
227
Forks
185
PR merge metrics
No merged PRs in 30d

Description

Hello!

I've been trying to save a photo using this plugin.

I'm setting `storeToFile: true` in the CameraPreviewOption to start the camera beforehand.

```javascript
const options: CameraPreviewOptions = {
storeToFile: true,
width: window.screen.width,
height: window.screen.height,
parent: "cameraPreview",
position: "rear",
className: "cameraPreview",
enableOpacity: true,
toBack: true,
lockAndroidOrientation: true,
rotateWhenOrientationChanged: false,
}
CameraPreview.start(options);
```

But then when I try to capture an image, as a result I still get a base64 string.

```javascript
const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
quality: 90,
};
const result = await CameraPreview.capture(cameraPreviewPictureOptions);
```

I wanted to check if this is the correct way to use the storeToFile property, since I need a file instead of a base64 string. Accessing results.value just gives me the entire base64 string.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.