Skip to main content

parse_jpeg_exif

Function parse_jpeg_exif 

Source
pub fn parse_jpeg_exif<R: Read + Seek>(reader: R) -> Result<Option<Exif>>
๐Ÿ‘ŽDeprecated since 2.0.0
Expand description

Deprecated: Please use MediaParser + MediaSource instead.

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", "2023-07-09T20:36:33+08:00"),
        ("CreateDate", "2023-07-09T20:36:33+08:00"),
        ("ModifyDate", "2023-07-09T20:36:33+08:00")
    ]
    .into_iter()
    .map(|x| (x.0.to_string(), x.1.to_string()))
    .collect::<Vec<_>>()
);