pub struct Metadata { /* private fields */ }
Expand description

An opaque structure that serves as a container for a media file’s metadata.

Implementations

Load the metadata from the file found at the given path.

Examples
let path = "myphoto.jpg";
let meta = rexiv2::Metadata::new_from_path(&path)?;
assert_eq!(meta.get_media_type()?, rexiv2::MediaType::Jpeg);

Load the metadata from the given Exif data buffer.

This is usually the data in the JPEG APP1 segment.

Load the metadata from the given data buffer.

Examples
let minipng = [137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1,
               0, 0, 0, 1, 8, 0, 0, 0, 0, 58, 126, 155, 85, 0, 0, 0, 10, 73, 68, 65, 84,
               8, 215, 99, 248, 15, 0, 1, 1, 1, 0, 27, 182, 238, 86, 0, 0, 0, 0, 73, 69,
               78, 68, 174, 66, 96, 130];
let meta = rexiv2::Metadata::new_from_buffer(&minipng)?;
assert_eq!(meta.get_media_type()?, rexiv2::MediaType::Png);

Save metadata to the file found at the given path, which must already exist.

Determine whether the type of file loaded supports Exif metadata.

Determine whether the type of file loaded supports IPTC metadata.

Determine whether the type of file loaded supports XMP metadata.

Return the media type of the loaded file.

Get the actual un-rotated/un-oriented pixel width of the loaded image.

Note that this may be different from the values reported by some metadata tags that take into account the intended orientation of the image.

Examples
assert_eq!(meta.get_pixel_width(), 1);

Get the actual un-rotated/un-oriented pixel height of the loaded image.

Note that this may be different from the values reported by some metadata tags that take into account the intended orientation of the image.

Examples
assert_eq!(meta.get_pixel_height(), 1);

Indicates whether the given tag is present/populated in the loaded metadata.

Examples
assert!(!meta.has_tag("Exif.Image.DateTime"));
meta.set_tag_string("Exif.Image.DateTime", "2022-08-07 11:19:44");
assert!(meta.has_tag("Exif.Image.DateTime"));

Removes the tag from the metadata if it exists. Returns whether it was there originally.

Examples
assert!(meta.has_tag("Exif.Image.DateTime"));
assert!(meta.clear_tag("Exif.Image.DateTime"));
assert!(!meta.has_tag("Exif.Image.DateTime"));

Remove all tag values from the metadata.

Examples
assert!(meta.has_tag("Exif.Image.DateTime"));
meta.clear();
assert!(!meta.has_tag("Exif.Image.DateTime"));

Indicates whether the loaded file contains any Exif metadata.

Examples
assert!(!meta.has_exif());
meta.set_tag_string("Exif.Image.DateTime", "2022-08-07 11:19:44");
assert!(meta.has_exif());

Removes all Exif metadata, leaving other types of metadata intact.

Examples
meta.set_tag_string("Exif.Image.DateTime", "2022-08-07 11:19:44");
meta.set_tag_string("Xmp.dc.Title", "Test");
assert!(meta.has_exif());
assert!(meta.has_xmp());
meta.clear_exif();
assert!(!meta.has_exif());
assert!(meta.has_xmp());

List all Exif tags present in the loaded metadata.

Examples
assert_eq!(meta.get_exif_tags(), Ok(vec!["Exif.Image.DateTime".to_string()]));

Indicates whether the loaded file contains any XMP metadata.

Examples
assert!(!meta.has_xmp());
meta.set_tag_string("Xmp.dc.Title", "Test Image");
assert!(meta.has_xmp());

Removes all XMP metadata, leaving all other types of metadata intact.

Examples
meta.set_tag_string("Xmp.dc.Title", "Test Image");
meta.set_tag_string("Exif.Image.DateTime", "2022-08-07 11:19:44");
assert!(meta.has_xmp());
assert!(meta.has_exif());
meta.clear_xmp();
assert!(!meta.has_xmp());
assert!(meta.has_exif());

List all XMP tags present in the loaded metadata.

Examples
meta.set_tag_string("Xmp.dc.Title", "Test Image");
assert_eq!(meta.get_xmp_tags(), Ok(vec!["Xmp.dc.Title".to_string()]));

Indicates whether the loaded file contains any IPTC metadata.

Examples
assert!(!meta.has_iptc());
meta.set_tag_string("Iptc.Application2.Subject", "Test Image");
assert!(meta.has_iptc());

Removes all XMP metadata, leaving all other types of metadata intact.

Examples
meta.set_tag_string("Iptc.Application2.Subject", "Test Image");
meta.set_tag_string("Exif.Image.DateTime", "2022-08-07 11:19:44");
assert!(meta.has_iptc());
assert!(meta.has_exif());
meta.clear_iptc();
assert!(!meta.has_iptc());
assert!(meta.has_exif());

List all IPTC tags present in the loaded metadata.

Examples
meta.set_tag_string("Iptc.Application2.Subject", "Test Image");
assert_eq!(meta.get_iptc_tags(), Ok(vec!["Iptc.Application2.Subject".to_string()]));

Get the value of a tag as a string.

Only safe if the tag is really of a string type.

Examples
assert_eq!(meta.get_tag_string("Iptc.Application2.Subject"), Ok("Test Image".to_string()));

Set the value of a tag to the given string.

Only safe if the tag is really of a string type.

Examples
meta.set_tag_string("Iptc.Application2.Subject", "Test Image");
assert_eq!(meta.get_tag_string("Iptc.Application2.Subject"), Ok("Test Image".to_string()));

Get the value of a tag as a string, potentially formatted for user-visible display.

Only safe if the tag is really of a string type.

Retrieve the list of string values of the given tag.

Only safe if the tag is in fact of a string type.

Store the given strings as the values of a tag.

Get the value of a tag as a number.

Only safe if the tag is really of a numeric type.

Examples
assert_eq!(meta.get_tag_numeric("Exif.Photo.MaxApertureValue"), 5);

Set the value of a tag to the given number.

Only safe if the tag is really of a numeric type.

Examples
assert_eq!(meta.get_tag_numeric("Exif.Photo.MaxApertureValue"), 5);

Get the value of a tag as a Rational.

Only safe if the tag is in fact of a rational type.

Examples
let ratio = num_rational::Ratio::new_raw(16, 10);
assert_eq!(meta.get_tag_rational("Exif.Photo.MaxApertureValue"), Some(ratio));

Set the value of a tag to a Rational.

Only safe if the tag is in fact of a rational type.

Examples
let ratio = num_rational::Ratio::new_raw(16, 10);
meta.set_tag_rational("Exif.Photo.MaxApertureValue", &ratio);
assert_eq!(meta.get_tag_rational("Exif.Photo.MaxApertureValue"), Some(ratio));

Get the value of a tag as raw data.

Examples
assert_eq!(meta.get_tag_raw("Exif.Photo.MaxApertureValue"), Ok(vec![0, 0, 0, 16, 0, 0, 0, 10]));

Find out the orientation the image should have, according to the metadata tag.

Examples
assert_eq!(meta.get_orientation(), rexiv2::Orientation::Unspecified);

Set the intended orientation for the image.

Examples
assert_eq!(meta.get_orientation(), rexiv2::Orientation::Unspecified);
meta.set_orientation(rexiv2::Orientation::VerticalFlip);
assert_eq!(meta.get_orientation(), rexiv2::Orientation::VerticalFlip);

Returns the camera exposure time of the photograph.

Examples
assert_eq!(meta.get_exposure_time(), Some(num_rational::Ratio::new_raw(1, 1000)));

Returns the f-number used by the camera taking the photograph.

Returns the focal length used by the camera taking the photograph.

Returns the ISO speed used by the camera taking the photograph.

Examples
assert_eq!(meta.get_iso_speed(), Some(600));

Get the thumbnail stored in the EXIF data.

Remove the thumbnail from the EXIF data.

Set or replace the EXIF thumbnail with the image in the file.

Set or replace the EXIF thumbnail with the content of a buffer.

Return the all the preview images found in this EXIF data.

Retrieve the stored GPS information from the loaded file.

Save the specified GPS values to the metadata.

Remove all saved GPS information from the metadata.

Trait Implementations

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.