camera-preview icon indicating copy to clipboard operation
camera-preview copied to clipboard

How to properly obtain the image file using storeToFile: true

Open sergio-asenjo opened this issue 3 years ago • 2 comments

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.

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.

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.

sergio-asenjo avatar Mar 17 '22 16:03 sergio-asenjo

I'm having the same issue. Did you manage to get the file path?

marcosbarbosa031 avatar Jul 25 '22 20:07 marcosbarbosa031

I'm having the same issue. Did you manage to get the file path?

Not really, I ended up using just the base64 it gives back. I believe that you would have to save that base64 with a different plugin and get the path back from there, or default back to the official camera plugin.

sergio-asenjo avatar Sep 02 '22 13:09 sergio-asenjo