Function nom_exif::parse_heif_exif

source ·
pub fn parse_heif_exif<R: Read + Seek>(reader: R) -> Result<Option<Exif>>
Expand description

Analyze the byte stream in the reader as a HEIF/HEIC file, attempting to extract Exif data it may contain.

Please note that the parsing routine itself provides a buffer, so the reader may not need to be wrapped with BufRead.

§Usage

use nom_exif::*;
use nom_exif::ExifTag::*;

use std::fs::File;
use std::path::Path;

let f = File::open(Path::new("./testdata/exif.heic")).unwrap();
let exif = parse_heif_exif(f).unwrap().unwrap();

assert_eq!(exif.get_value(&Make).unwrap().unwrap().to_string(), "Apple");

assert_eq!(
    exif.get_values(&[DateTimeOriginal, CreateDate, ModifyDate])
        .into_iter()
        .map(|x| (x.0.to_string(), x.1.to_string()))
        .collect::<Vec<_>>(),
    [
        ("DateTimeOriginal(0x9003)", "2022-07-22T21:26:32+08:00"),
        ("CreateDate(0x9004)", "2022-07-22T21:26:32+08:00"),
        ("ModifyDate(0x0132)", "2022-07-22T21:26:32+08:00")
    ]
    .into_iter()
    .map(|x| (x.0.to_string(), x.1.to_string()))
    .collect::<Vec<_>>()
);