exiftool/
lib.rs

1//! # ExifTool
2//!
3//! A Rust wrapper library for Phil Harvey's ExifTool command-line application.
4//!
5//! This library allows you to interact with ExifTool, enabling reading and writing
6//! metadata tags for a wide variety of file types (images, videos, audio, documents).
7//!
8//! It maintains a long-running ExifTool process in stay-open mode for efficiency when
9//! processing multiple files or commands.
10//!
11//! ## Basic Usage
12//!
13//! ```no_run
14//! use exiftool::{ExifTool, ExifToolError};
15//! use std::path::Path;
16//!
17//! fn main() -> Result<(), ExifToolError> {
18//!     let mut exiftool = ExifTool::new()?; // Starts the background ExifTool process
19//!     let image_path = Path::new("path/to/your/image.jpg");
20//!
21//!     // Read a specific tag as a JSON Value
22//!     let author_value = exiftool.json_tag(image_path, "Author")?;
23//!     if let Some(author) = author_value.as_str() {
24//!         println!("Author: {}", author);
25//!     }
26//!
27//!     // Read all metadata as a JSON Value (grouped by category)
28//!     let metadata_json = exiftool.json(image_path, &["-g1"])?;
29//!     println!("Metadata JSON: {}", metadata_json);
30//!
31//!     // Write a tag
32//!     exiftool.write_tag(image_path, "UserComment", "This is a test comment", &["-overwrite_original"])?;
33//!
34//!     // Read binary data (e.g., thumbnail)
35//!     let thumbnail_bytes = exiftool.read_tag_binary(image_path, "ThumbnailImage")?;
36//!     println!("Read {} bytes for thumbnail", thumbnail_bytes.len());
37//!
38//!     // Remember ExifTool process closes when `exiftool` variable goes out of scope (Drop).
39//!     Ok(())
40//! }
41//! ```
42//!
43//!
44//! ```no_run
45//! use exiftool::{ExifTool, ExifToolError};
46//! use std::path::Path;
47//! use serde::Deserialize;
48//!
49//! #[derive(Deserialize, Debug)]
50//! struct ImageMetadata {
51//!     #[serde(rename = "FileName")]
52//!     file_name: String,
53//!     #[serde(rename = "ImageWidth")]
54//!     width: u32,
55//!     #[serde(rename = "ImageHeight")]
56//!     height: u32,
57//! }
58//!
59//! fn main() -> Result<(), ExifToolError> {
60//!     let mut exiftool = ExifTool::new()?;
61//!     let image_path = Path::new("path/to/your/image.jpg");
62//!
63//!     // Read specific tags and deserialize into a struct
64//!     let partial_meta: ImageMetadata = exiftool.read_tags(
65//!         image_path,
66//!         &["FileName", "ImageWidth", "ImageHeight"]
67//!     )?;
68//!     println!("Partial Metadata: {:?}", partial_meta);
69//!
70//!     // Read all metadata (grouped) and deserialize
71//!     // Note: Requires a struct matching ExifTool's -g/-G output structure
72//!     // let full_meta: YourFullMetadataStruct = exiftool.read_metadata(image_path, &["-g1"])?;
73//!     // println!("Full Metadata: {:?}", full_meta);
74//!
75//!     // Read a single tag and deserialize
76//!     let author: String = exiftool.read_tag(image_path, "Author")?;
77//!     println!("Author: {}", author);
78//!
79//!     Ok(())
80//! }
81//! ```
82
83// Public API
84mod error;
85mod exiftool;
86
87pub use error::ExifToolError;
88pub use exiftool::ExifTool;
89
90pub mod parse_fn;
91mod structs;
92pub use structs::g2::ExifData;
93
94mod utils;