Nom-Exif
nom-exif is an Exif/metadata parsing library written in pure Rust with nom, both JPEG/HEIF/HEIC images and MOV/MP4 videos are supported.
Supporting both sync and async interfaces. The interface design is simple and easy to use.
Key Features
-
Supports both sync and async interfaces.
-
Supports two style interfaces, iterator (
ExifIter) and get (Exif). The former is fully functional and the latter is simple and easy to use. -
Performance
-
Zero-copy when appropriate: Use borrowing and slicing instead of copying whenever possible.
-
Minimize I/O operations: When metadata is stored at the end/middle of a large file (such as a QuickTime file does),
Seekrather thanReadto quickly locate the location of the metadata. -
Pay as you go: When working with
ExifIter, all entries are lazy-parsed. That is, only when you iterate overExifIterwill the IFD entries be parsed one by one.
-
-
Robustness and stability: Through long-term Fuzz testing, and tons of crash issues discovered during testing have been fixed. Thanks to @sigaloid for pointing this out!
Supported File Types
- Images
- JPEG
- HEIF/HEIC
- Videos
- MOV
- MP4
Sync API Usage
use *;
use File;
Async API Usage
Enable async feature flag for nom-exif in your Cargo.toml:
[]
= { = "1", = ["async"] }
Since parsing process is a CPU-bound task, you may want to move the job to a separated thread (better to use rayon crate). There is a simple example below.
You can safely and cheaply clone an [ExifIter] in multiple tasks/threads
concurrently, since it use Arc to share the underlying memory.
use ;
use spawn_blocking;
use File;
async
GPS Info
ExifIter provides a convenience method for parsing gps information.
(Exif also provides a get_gps_info mthod).
use *;
use File;
For more usage details, please refer to the API documentation.
CLI Tool rexiftool
Normal output
cargo run --example rexiftool testdata/meta.mov:
com.apple.quicktime.make => Apple
com.apple.quicktime.model => iPhone X
com.apple.quicktime.software => 12.1.2
com.apple.quicktime.location.ISO6709 => +27.1281+100.2508+000.000/
com.apple.quicktime.creationdate => 2019-02-12T15:27:12+08:00
duration => 500
width => 720
height => 1280
Json dump
cargo run --features json_dump --example rexiftool -- -j testdata/meta.mov:
{
"height": "1280",
"duration": "500",
"width": "720",
"com.apple.quicktime.creationdate": "2019-02-12T15:27:12+08:00",
"com.apple.quicktime.make": "Apple",
"com.apple.quicktime.model": "iPhone X",
"com.apple.quicktime.software": "12.1.2",
"com.apple.quicktime.location.ISO6709": "+27.1281+100.2508+000.000/"
}