takePhoto
Captures a photo with hardware-backed C2PA signing and returns a ZPhoto.
Usage
const camera = useRef<ZCamera>(null);
const photo = await camera.current?.takePhoto();
console.log(photo.path); // C2PA-signed photo pathParameters
options (optional)
- Type:
TakePhotoOptions - Default:
{}
Options for this specific capture. All fields are optional with sensible defaults.
type TakePhotoOptions = {
format?: "jpeg" | "dng"; // Capture format (default: "jpeg")
flash?: FlashMode; // Flash mode (default: "off")
includeDepthData?: boolean; // Include depth data in C2PA (default: false)
aspectRatio?: AspectRatio; // Photo aspect ratio (default: "4:3")
orientation?: Orientation; // Crop orientation (default: "auto")
}Returns
Promise<ZPhoto>
A photo object with paths to the original and C2PA-signed images:
class ZPhoto {
originalPath: string; // Path to raw captured image
path: string; // Path to C2PA-signed image with succinct.bindings
}The path property contains a C2PA manifest with hardware-backed attestation required for proof generation.
Example
import { useRef } from "react";
import { Button } from "react-native";
import { ZCamera } from "@succinctlabs/react-native-zcam1";
import { FileSystem, Dirs } from "react-native-file-access";
function CameraScreen({ captureInfo }) {
const camera = useRef<ZCamera>(null);
const handleCapture = async () => {
const photo = await camera.current?.takePhoto({
flash: "auto",
aspectRatio: "4:3"
});
if (!photo) return;
// Save to app's document directory
const destPath = `${Dirs.DocumentDir}/photos/${Date.now()}.jpg`;
await FileSystem.mkdir(`${Dirs.DocumentDir}/photos`);
await FileSystem.cp(photo.path, destPath);
console.log("Saved C2PA-signed photo:", destPath);
};
return (
<>
<ZCamera ref={camera} captureInfo={captureInfo} />
<Button title="Capture" onPress={handleCapture} />
</>
);
}Notes
- The returned
photo.pathcontains a C2PA manifest withsuccinct.bindingsassertion - This C2PA manifest is required for proof generation with the Prove SDK
- App Attest assertions are generated over the photo hash during capture
- On simulators, mock attestation values are used for development