Expand description
§Upgrade Guide
§Upgrade from 0.4.x to 0.5.x
§API compatibilities
-
Readerhas been split into two:ReaderandExif.Readeris now the builder forExif, andExifprovides access toFields viaget_field,fields, and other methods. Old codeReader::new(data)should be changed toReader::new().read_raw(data)orReader::new().read_from_container(data).The old code using 0.4.x:
ⓘlet reader = Reader::new(&mut bufreader).unwrap(); for f in reader.fields() { /* do something */ }The new code using 0.5.x:
let exif = Reader::new().read_from_container(&mut bufreader).unwrap(); for f in exif.fields() { /* do something */ }
§Other new features
- Support for parsing Exif in HEIF (HEIC/AVIF) has been added.
§Upgrade from 0.3.x to 0.4.x
§API compatibilities
- Use struct
Ininstead ofboolto indicate primary/thumbnail images.- On
Reader::get_field, the old code using 0.3.x:ⓘThe new code using 0.4.x:reader.get_field(Tag::DateTime, false)ⓘAs an additional feature, access to the 2nd or further IFD, which some TIFF-based RAW formats may have, is also possible with 0.4.x:reader.get_field(Tag::DateTime, In::PRIMARY)ⓘreader.get_field(Tag::ImageWidth, In(2)) - On
Field, the old code using 0.3.x:ⓘThe new code using 0.4.x:if field.thumbnail { // for the thumbnail image } else { // for the primary image }match field.ifd_num { In::PRIMARY => {}, // for the primary image In::THUMBNAIL => {}, // for the thumbnail image _ => {}, }
- On
Reader::fieldsnow returns an iterator instead of a slice.- Enum variants of
ContextandErrorare no longer exhaustive. You need a wildcard arm (_) in a match expression. - The associated value of
Value::UndefinedandValue::Asciihas been changed from a slice to aVec.
§Other new features
Field::display_valuehas been introduced. It is usually handier thanValue::display_as.assert_eq!(field.display_value().to_string(), field.value.display_as(field.tag).to_string());- Displaying a value with its unit is supported.
ⓘ
// Display the value only. println!("{}", field.display_value()); // Display the value with its unit. If the unit depends on another // field, it is taken from the reader. println!("{}", field.display_value().with_unit(&reader)); ValueandFieldare self-contained and no longer borrow the raw buffer orReader(thanks to the change ofValue::UndefinedandValue::Asciidescribed above).