Rust
Rust
Get a String Property Value from XMP
See more XMP Examples
Demonstrates how to open a JPG or TIF image file, access the XMP metadata, and fetch the value of a string property, such as the Location.Chilkat Rust Downloads
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let xmp = chilkat::Xmp::new();
// Load a JPG or TIF image file.
// Sample JPG's with XMP metadata may be found at:
// http://www.chilkatsoft.com/testData/xmp/sample1.jpg
// http://www.chilkatsoft.com/testData/xmp/sample2.jpg
// http://www.chilkatsoft.com/testData/xmp/sample3.jpg
if xmp.load_app_file("sample1.jpg").is_err() {
println!("{}", xmp.last_error_text());
return;
}
println!("Num embedded XMP docs: {}", xmp.num_embedded());
// Assuming there is at least one, get the 1st.
// (There is typically never more than one, but theoretically it's possible.)
if let Ok(xml) = xmp.get_embedded(0) {
let prop_val = xmp.get_simple_str(&xml, "Iptc4xmpCore:Location").unwrap_or_default();
if !xmp.last_method_success() {
println!("Not found.");
} else {
println!("{}", prop_val);
}
} else {
println!("{}", xmp.last_error_text());
}