type FetchLike = (...args: any[]) => Promise; /** * Configuration options for parsing file metadata with ExifTool * @template TReturn The type of the transformed output data */ export interface ExifToolOptions { /** * Additional command-line arguments to pass to ExifTool * * @example * // Extract specific tags * args: ["-Author", "-CreateDate"] * * @example * // Output as JSON * args: ["-json", "-n"] * * @see https://exiftool.org/exiftool_pod.html for all available options */ args?: string[]; /** * Custom fetch implementation for loading the WASM module * * Only needed for environments with custom fetch polyfills */ fetch?: FetchLike; /** * Transform the raw ExifTool output into a different format * * @example * // Parse output as JSON * transform: (data) => JSON.parse(data) */ transform?: (data: string) => TReturn; } /** * Represents a binary file for metadata extraction */ export type Binaryfile = { /** Filename with extension (e.g., "image.jpg") */ name: string; /** The binary content of the file */ data: Uint8Array | Blob; }; /** * Result of an ExifTool metadata extraction operation * @template TOutput The type of the output data after transformation */ export type ExifToolOutput = { /** True when metadata was successfully extracted */ success: true; /** The extracted metadata, transformed if a transform function was provided */ data: TOutput; /** Any warnings or info messages from ExifTool */ error: string; /** Always 0 for success */ exitCode: 0; } | { /** False when metadata extraction failed */ success: false; /** No data available on failure */ data: undefined; /** Error message explaining why the operation failed */ error: string; /** Non-zero exit code indicating the type of failure */ exitCode: number | undefined; }; /** Defines possible values for a tag when using `TagsObject`. */ export type TagValue = string | number | boolean | (string | number | boolean)[]; /** * Represents tags as a JavaScript object for writing metadata. * Keys are tag names (e.g., "Comment", "IPTC:Keywords"), and values are the data. * @example { "IPTC:Credit": "Photographer", "IPTC:Keywords": ["test", "keyword"] } */ export type TagsObject = Record; /** Configuration options for writing file metadata with ExifTool. */ export interface ExifToolWriteOptions { /** * Tags to write to the file. Can be provided in two formats: * 1. An array of strings, where each string is a complete ExifTool tag assignment argument. * Example: `["-Comment=My Description", "-Artist=John Doe"]` * 2. A JavaScript object (`TagsObject`) where keys are tag names and values are the data. * Example: `{ "Comment": "My Description", "IPTC:Keywords": ["test", "image"] }` * This object will be transformed into individual tag assignment arguments. * * @see https://exiftool.org/exiftool_pod.html#Writing-Meta-Information for tag names and values. */ tags: string[] | TagsObject; /** Optional: Custom ExifTool config file for defining custom tags. */ configFile?: { name: string; data: Uint8Array; }; /** Custom fetch implementation. */ fetch?: FetchLike; /** * Additional command-line arguments for ExifTool (e.g., `-m` for ignore minor errors). * Avoid input/output filenames or tag assignments here. * For importing from a JSON file via ExifTool's `-j=JSONFILE`, ensure the file is in * the virtual FS and pass `"-j=/path/to/yourfile.json"` here. */ extraArgs?: string[]; } /** * Result of an ExifTool metadata writing operation */ export type ExifToolWriteResult = { /** True when metadata was successfully written */ success: true; /** The binary data of the modified file */ data: Uint8Array; /** Any warnings or info messages from ExifTool (stderr) */ warnings: string; /** Always 0 for success */ exitCode: 0; } | { /** False when metadata writing failed */ success: false; /** No data available on failure */ data: undefined; /** Error message explaining why the operation failed (stderr) */ error: string; /** Non-zero exit code indicating the type of failure */ exitCode: number | undefined; }; /** * Extract metadata from a file using ExifTool * * @template TReturn Type of the returned data after transformation (defaults to string) * @param file File to extract metadata from * @param options Configuration options * @returns Promise resolving to the extraction result * * @example * // Basic usage with browser File object * const input = document.querySelector('input[type="file"]'); * input.addEventListener('change', async () => { * const file = input.files[0]; * const result = await parseMetadata(file); * if (result.success) { * console.log(result.data); // Raw ExifTool output as string * } * }); * * @example * // Extract specific tags and transform to JSON * const result = await parseMetadata(file, { * args: ["-json"], * transform: (data) => JSON.parse(data) * }); * if (result.success) { * console.log(result.data); // Typed access to specific metadata * } */ export declare function parseMetadata(file: Binaryfile | File, options?: ExifToolOptions): Promise>; /** * Writes metadata to a file using ExifTool. * The operation creates a modified copy of the file in memory. * * @param file The file (browser `File` or `Binaryfile`) to write metadata to. * @param options Configuration for tags, ExifTool config, and other arguments. * @returns A promise resolving to the write result, with modified file data on success. */ export declare function writeMetadata(file: Binaryfile | File, options: ExifToolWriteOptions): Promise; export {};