peck-exif

Crates.iopeck-exif
lib.rspeck-exif
version1.0.1
sourcesrc
created_at2022-03-27 12:18:30.770768
updated_at2022-03-27 12:30:56.339862
descriptionExif reader
homepage
repositoryhttps://github.com/alexipeck/exif
max_upload_size
id557241
size11,155
Alexi Peck (alexipeck)

documentation

README

Exif reader. Pull all exif tags and values from a file, requires exiftool to be installed. There are 3 modes of importing, All, Whitelist and Blacklist.

pub const TEST_FILE_PATH: &str = r"PATH_TO_FILE";
pub fn main() {
    if !exiftool_available() {
        //handle error
        panic!("Exiftool not available for execution.");
    }
    
    //pull all exif tags/values
    match Exif::new(Path::new(TEST_FILE_PATH), Mode::All) {
        Ok(exif) => {
            for (tag, value) in exif.attributes.iter() {
                println!("{}:{}", tag, value);
            }
        }
        Err(err) => {
            //handle error
            panic!("{}", err);
        }
    };
    
    //pull exif tags/values filtered by whitelist
    let whitelist = create_list_from_vec(vec![
        "GPSLatitude",
        "GPSLongitude",
        "GPSAltitude",
        "ExifImageWidth",
        "ExifImageHeight",
        "FlightYawDegree",
        "AbsoluteAltitude",
        "RelativeAltitude",
        "FieldOfView",
        "FocalLength",
    ]);
    match Exif::new(Path::new(TEST_FILE_PATH), Mode::Whitelist(whitelist)) {
        Ok(exif) => {
            for (tag, value) in exif.attributes.iter() {
                println!("{}:{}", tag, value);
            }
        }
        Err(err) => {
            //handle error
            panic!("{}", err);
        }
    };
    
    //pull exif tags/values filtered by blacklist
    let blacklist = create_list_from_vec(vec![
        "SerialNumber",
        "FileModificationDate/Time",
        "DigitalZoomRatio",
        "XPComment",
        "XPKeywords",
    ]);
    match Exif::new(Path::new(TEST_FILE_PATH), Mode::Blacklist(blacklist)) {
        Ok(exif) => {
            for (tag, value) in exif.attributes.iter() {
                println!("{}:{}", tag, value);
            }
        }
        Err(err) => {
            //handle error
            panic!("{}", err);
        }
    };
}
Commit count: 15

cargo fmt