Function nom_exif::parse_jpeg_exif
source · pub fn parse_jpeg_exif<R: Read>(reader: R) -> Result<Option<Exif>>
Expand description
Analyze the byte stream in the reader
as a JPEG 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.jpg")).unwrap();
let exif = parse_jpeg_exif(f).unwrap().unwrap();
assert_eq!(exif.get_value(&Make).unwrap().unwrap().to_string(), "vivo");
assert_eq!(
exif.get_values(&[DateTimeOriginal, CreateDate, ModifyDate])
.into_iter()
.map(|x| (x.0.to_string(), x.1.to_string()))
.collect::<Vec<_>>(),
[
("DateTimeOriginal(0x9003)", "2023-07-09T20:36:33+08:00"),
("CreateDate(0x9004)", "2023-07-09T20:36:33+08:00"),
("ModifyDate(0x0132)", "2023-07-09T20:36:33+08:00")
]
.into_iter()
.map(|x| (x.0.to_string(), x.1.to_string()))
.collect::<Vec<_>>()
);