pub struct ExifTool { /* private fields */ }Expand description
The main ExifTool engine — read, write, and edit metadata.
§Reading metadata
use exiftool_rs::ExifTool;
let et = ExifTool::new();
// Full tag structs
let tags = et.extract_info("photo.jpg").unwrap();
for tag in &tags {
println!("[{}] {}: {}", tag.group.family0, tag.name, tag.print_value);
}
// Simple name→value map
let info = et.image_info("photo.jpg").unwrap();
println!("Camera: {}", info.get("Model").unwrap_or(&String::new()));§Writing metadata
use exiftool_rs::ExifTool;
let mut et = ExifTool::new();
et.set_new_value("Artist", Some("John Doe"));
et.set_new_value("Copyright", Some("2024"));
et.write_info("input.jpg", "output.jpg").unwrap();Implementations§
Source§impl ExifTool
impl ExifTool
Sourcepub fn with_options(options: Options) -> Self
pub fn with_options(options: Options) -> Self
Create a new ExifTool instance with custom options.
Sourcepub fn options_mut(&mut self) -> &mut Options
pub fn options_mut(&mut self) -> &mut Options
Get a mutable reference to the options.
Sourcepub fn set_new_value(&mut self, tag: &str, value: Option<&str>)
pub fn set_new_value(&mut self, tag: &str, value: Option<&str>)
Queue a new tag value for writing.
Call this one or more times, then call write_info() to apply changes.
§Arguments
tag- Tag name, optionally prefixed with group (e.g., “Artist”, “XMP:Title”, “EXIF:Copyright”)value- New value, or None to delete the tag
§Example
use exiftool_rs::ExifTool;
let mut et = ExifTool::new();
et.set_new_value("Artist", Some("John Doe"));
et.set_new_value("Copyright", Some("2024 John Doe"));
et.set_new_value("XMP:Title", Some("My Photo"));
et.write_info("photo.jpg", "photo_out.jpg").unwrap();Sourcepub fn clear_new_values(&mut self)
pub fn clear_new_values(&mut self)
Clear all queued new values.
Sourcepub fn set_new_values_from_file<P: AsRef<Path>>(
&mut self,
src_path: P,
tags_to_copy: Option<&[&str]>,
) -> Result<u32>
pub fn set_new_values_from_file<P: AsRef<Path>>( &mut self, src_path: P, tags_to_copy: Option<&[&str]>, ) -> Result<u32>
Copy tags from a source file, queuing them as new values.
Reads all tags from src_path and queues them for writing.
Optionally filter by tag names.
Sourcepub fn set_file_name_from_tag<P: AsRef<Path>>(
&self,
path: P,
tag_name: &str,
template: &str,
) -> Result<String>
pub fn set_file_name_from_tag<P: AsRef<Path>>( &self, path: P, tag_name: &str, template: &str, ) -> Result<String>
Set a file’s name based on a tag value.
Sourcepub fn write_info<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src_path: P,
dst_path: Q,
) -> Result<u32>
pub fn write_info<P: AsRef<Path>, Q: AsRef<Path>>( &self, src_path: P, dst_path: Q, ) -> Result<u32>
Write queued changes to a file.
If dst_path is the same as src_path, the file is modified in-place
(via a temporary file).
Returns the set of tag names (lowercase) that are writable for a given file type.
Returns None if any tag is writable (open-ended formats like PNG, FLAC, MKV).
Returns Some(empty set) if the format has no writer.
Sourcepub fn image_info<P: AsRef<Path>>(&self, path: P) -> Result<ImageInfo>
pub fn image_info<P: AsRef<Path>>(&self, path: P) -> Result<ImageInfo>
Extract metadata from a file and return a simple name→value map.
This is the high-level one-shot API, equivalent to ExifTool’s ImageInfo().