diff --git a/README.md b/README.md index a19a620..2386a4b 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,9 @@ - - - - - - - - - - - - # Nom-Exif ![nom-exif workflow](/~https://github.com/mindeng/nom-exif/actions/workflows/rust.yml/badge.svg) Exif/metadata parsing library written in pure Rust with [nom](/~https://github.com/rust-bakery/nom). - - - ## Supported File Types - Images @@ -28,9 +13,6 @@ Exif/metadata parsing library written in pure Rust with [nom](https://github.com - MOV - MP4 - - - ## Features - **Zero-copy when appropriate:** Use borrowing and slicing instead of copying @@ -42,73 +24,9 @@ Exif/metadata parsing library written in pure Rust with [nom](https://github.com to the specified Exif tags are parsed to reduce the overhead when processing a large number of files. - - - ## Usage - - - -### Parse Exif from Images - -``` rust -use nom_exif::*; -use nom_exif::ExifTag::*; - -use std::fs::File; -use std::path::Path; -use std::collections::HashMap; - -let f = File::open(Path::new("./testdata/exif.jpg")).unwrap(); -let exif = parse_jpeg_exif(f).unwrap().unwrap(); - -assert_eq!( - exif.get_value(&ImageWidth).unwrap(), - Some(IfdEntryValue::U32(3072))); - -assert_eq!( - exif.get_values(&[CreateDate, ModifyDate, DateTimeOriginal]), - [ - (&CreateDate, "2023:07:09 20:36:33"), - (&ModifyDate, "2023:07:09 20:36:33"), - (&DateTimeOriginal, "2023:07:09 20:36:33"), - ] - .into_iter() - .map(|x| (x.0, x.1.into())) - .collect::>() -); -``` - - - - -### Parse metadata from Videos - -``` rust -use nom_exif::*; - -use std::fs::File; -use std::path::Path; - -let f = File::open(Path::new("./testdata/meta.mov")).unwrap(); -let entries = parse_mov_metadata(reader).unwrap(); - -assert_eq!( - entries - .iter() - .map(|x| format!("{x:?}")) - .collect::>() - .join("\n"), - r#"("com.apple.quicktime.make", Text("Apple")) -("com.apple.quicktime.model", Text("iPhone X")) -("com.apple.quicktime.software", Text("12.1.2")) -("com.apple.quicktime.location.ISO6709", Text("+27.1281+100.2508+000.000/")) -("com.apple.quicktime.creationdate", Text("2019-02-12T15:27:12+08:00"))"# -); -``` - -## Docs - -- [docs.rs](https://docs.rs/nom-exif/latest/) +- [`parse_heif_exif`](https://docs.rs/nom-exif/latest/nom_exif/fn.parse_heif_exif.html) +- [`parse_jpeg_exif`](https://docs.rs/nom-exif/latest/nom_exif/fn.parse_jpeg_exif.html) +- [`parse_mov_metadata`](https://docs.rs/nom-exif/latest/nom_exif/fn.parse_mov_metadata.html) - [examples](examples/) diff --git a/src/exif/value.rs b/src/exif/value.rs index c9310cc..4de96ec 100644 --- a/src/exif/value.rs +++ b/src/exif/value.rs @@ -14,8 +14,10 @@ use serde::{Deserialize, Serialize}; /// /// # Structure of IFD Entry /// +/// ```txt /// | 2 | 2 | 4 | 4 | /// | tag | data format | components num | data (value or offset) | +/// ``` /// /// # Data size /// @@ -28,6 +30,7 @@ use serde::{Deserialize, Serialize}; /// /// # Data format /// +/// ```txt /// | Value | 1 | 2 | 3 | 4 | 5 | 6 | /// |-----------------+---------------+---------------+----------------+-----------------+-------------------+--------------| /// | Format | unsigned byte | ascii strings | unsigned short | unsigned long | unsigned rational | signed byte | @@ -35,6 +38,7 @@ use serde::{Deserialize, Serialize}; /// | Value | 7 | 8 | 9 | 10 | 11 | 12 | /// | Format | undefined | signed short | signed long | signed rational | single float | double float | /// | Bytes/component | 1 | 2 | 4 | 8 | 4 | 8 | +/// ``` /// /// See: [Exif](https://www.media.mit.edu/pia/Research/deepview/exif.html). #[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] diff --git a/src/heif.rs b/src/heif.rs index 7a92fe1..4188c38 100644 --- a/src/heif.rs +++ b/src/heif.rs @@ -12,8 +12,11 @@ use crate::{ exif::check_exif_header, }; -/// parse a HEIF/HEIC file from `reader`, extract the exif information of the -/// specified `tags`. +/// 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 /// diff --git a/src/jpeg.rs b/src/jpeg.rs index 247b7c0..45daff9 100644 --- a/src/jpeg.rs +++ b/src/jpeg.rs @@ -8,8 +8,7 @@ use crate::{ }; /// Analyze the byte stream in the `reader` as a JPEG file, attempting to -/// extract any possible Exif information it may contain, and return it in the -/// form of key-value pairs. +/// 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`.