Crate rexif

source ·
Expand description

RExif is a native Rust create, written to extract EXIF data from JPEG and TIFF images.

Note that it is in very early stages of development. Any sort of feedback is welcome!

The crate contains a sample binary called ‘rexiftool’ that accepts files as arguments and prints the EXIF data. It gives a rough idea on how to use the crate. Get some sample images and run

cargo run [image file 1] [image file 2] ...

To learn to use this crate, start by the documentation of function parse_file(), and the struct ExifData that is returned by the parser. The rest falls more or less into place.

Code sample lightly edited from src/bin.rs:

use std::error::Error;

let file_name = "foo.jpg";
match rexif::parse_file(&file_name) {
    Ok(exif) => {
        println!("{} {} exif entries: {}", file_name, exif.mime, exif.entries.len());
        for entry in &exif.entries {
            println!("\t{}: {}", entry.tag, entry.value_more_readable);
        }
    },
    Err(e) => {
        eprintln!("Error in {}: {}", &file_name, e)
    }
}

Structs§

  • Top-level structure that contains all parsed metadata inside an image
  • Structure that represents a parsed EXIF tag.
  • Encapsulation of the TIFF type that represents a signed rational number
  • Structure that represents a parsed IFD entry of a TIFF image
  • Encapsulation of the TIFF type that represents an unsigned rational number

Enums§

  • Possible fatal errors that may happen when an image is parsed.
  • Enumeration that represents recognized EXIF tags found in TIFF IFDs.
  • Enumeration that represents the possible data formats of an IFD entry.
  • Enumeration that represent EXIF tag namespaces. Namespaces exist to accomodate future parsing of the manufacturer-specific tags embedded within the MarkerNote tag.
  • Tag value enumeration. It works as a variant type. Each value is actually a vector because many EXIF tags are collections of values. Exif tags with single values are represented as single-item vectors.

Constants§

Functions§

  • Parse a byte buffer that should contain a TIFF or JPEG image. Tries to detect format and parse EXIF data.
  • Parse a byte buffer that should contain a TIFF or JPEG image. Tries to detect format and parse EXIF data.
  • Opens an image (passed as a file name), tries to read and parse it.
  • Try to read and parse an open file that is expected to contain an image

Type Aliases§