Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

captureMetadata

Returns the capture metadata from the C2PA manifest. Contains device info and camera settings recorded at capture time.

Usage

import { VerifiableFile } from '@succinctlabs/react-native-zcam1';
 
const verifiable = new VerifiableFile(photoPath);
const metadata = verifiable.captureMetadata();
 
if (metadata) {
  console.log('Captured at:', metadata.when);
  console.log('Action:', metadata.action);
  console.log('Parameters:', metadata.parameters);
}

Returns

CaptureMetadata | null - The capture metadata object, or null if not present in the manifest.

Example

import { useState } from 'react';
import { Button, Text, View, ScrollView, StyleSheet } from 'react-native';
import { VerifiableFile, type CaptureMetadata } from '@succinctlabs/react-native-zcam1';
import { launchImageLibrary } from 'react-native-image-picker';
 
function MetadataDisplayScreen() {
  const [metadata, setMetadata] = useState<CaptureMetadata | null>(null);
 
  const getMetadata = async () => {
    const response = await launchImageLibrary({ mediaType: 'photo' });
    const uri = response.assets?.[0]?.uri;
    
    if (!uri) return;
 
    try {
      const verifiable = new VerifiableFile(uri);
      const meta = verifiable.captureMetadata();
      setMetadata(meta);
    } catch (error: any) {
      console.error('Error:', error.message);
    }
  };
 
  return (
    <ScrollView style={styles.container}>
      <Button title="Get Metadata" onPress={getMetadata} />
      {metadata && (
        <View style={styles.metadata}>
          <Text style={styles.label}>Action:</Text>
          <Text style={styles.value}>{metadata.action}</Text>
          
          <Text style={styles.label}>Captured:</Text>
          <Text style={styles.value}>{new Date(metadata.when).toLocaleString()}</Text>
          
          <Text style={styles.label}>Parameters:</Text>
          <Text style={styles.value}>{JSON.stringify(metadata.parameters, null, 2)}</Text>
        </View>
      )}
    </ScrollView>
  );
}

Notes

  • Returns null if the C2PA manifest doesn't contain capture metadata
  • The parameters field contains detailed device and camera information
  • For photos, parameters is of type PhotoMetadataInfo
  • For videos, parameters is of type VideoMetadataInfo
  • All timestamps are in ISO 8601 format
  • If a non-default film style was applied at capture time, parameters.filmStyle contains the style name, source, and full recipe (see FilmStyleInfo)