2 个稳定版本
1.0.1 | 2022年3月27日 |
---|
#5 in #allowlist
11KB
217 代码行数,不包括注释
Exif 读取器。从文件中提取所有 Exif 标签和值,需要已安装 exiftool。有三种导入模式:全部、白名单和黑名单。
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);
}
};
}