Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mindeng committed Feb 15, 2024
1 parent 02309a1 commit 375f094
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 89 deletions.
88 changes: 3 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
<!-- # Table of Contents -->

<!-- 1. [Nom-Exif](#orgcd5539d) -->
<!-- 1. [Supported File Types](#org85ad222) -->
<!-- 2. [Features](#org6d43624) -->
<!-- 3. [Usage](#org55e3f0a) -->
<!-- 1. [Parse Exif from Images](#orgd388296) -->
<!-- 2. [Parse metadata from Videos](#orgf7ffad0) -->


<a id="orgcd5539d"></a>

# 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).


<a id="org85ad222"></a>

## Supported File Types

- Images
Expand All @@ -28,9 +13,6 @@ Exif/metadata parsing library written in pure Rust with [nom](https://github.com
- MOV
- MP4


<a id="org6d43624"></a>

## Features

- **Zero-copy when appropriate:** Use borrowing and slicing instead of copying
Expand All @@ -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.


<a id="org55e3f0a"></a>

## Usage


<a id="orgd388296"></a>

### 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::<HashMap<_, _>>()
);
```


<a id="orgf7ffad0"></a>

### 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::<Vec<_>>()
.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/)
4 changes: 4 additions & 0 deletions src/exif/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -28,13 +30,15 @@ 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 |
/// | Bytes/component | 1 | 1 | 2 | 4 | 8 | 1 |
/// | 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))]
Expand Down
7 changes: 5 additions & 2 deletions src/heif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
3 changes: 1 addition & 2 deletions src/jpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 375f094

Please sign in to comment.