Code Monkey home page Code Monkey logo

nom-exif's Introduction

Nom-Exif

crates.io Documentation LICENSE CI

Exif/metadata parsing library written in pure Rust with nom.

Supported File Types

  • Images
    • JPEG
    • HEIF/HEIC
  • Videos
    • MOV
    • MP4

Features

  • 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 MOV/HEIC file does), Seek rather than Read to quickly locate the location of the metadata.
  • Pay as you go: When extracting Exif data, only the information corresponding to the specified Exif tags are parsed to reduce the overhead when processing a large number of files.

Usage

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/"
}

nom-exif's People

Contributors

mindeng avatar

Watchers

 avatar

nom-exif's Issues

Library cannot read file, that exiftool reads properly

        let file_reader = std::fs::File::open(i.path()).unwrap();
        match nom_exif::parse_jpeg_exif(file_reader) {
            Ok(_) => {
                println!("{}: OK", path_str);
            }
            Err(e) => {
                println!("{}: {}", path_str, e);
            }
        }

shows error

/home/rafal/Downloads/Untitled Folder/301581895-a7b4390a-e9f4-46cc-b04f-eb1ba677204c.jpg: parse failed; error: Map on Result; 

problematic file

301581895-a7b4390a-e9f4-46cc-b04f-eb1ba677204c.jpg.zip

exiftool only warning - properly parse entire file

[minor] Skipped unknown 7 bytes after JPEG APP1 segment

Panic when checking ramdisk file

    for i in WalkDir::new("/home/rafal/").into_iter().flatten() {
        println!("{}", i.path().display());
        let file_reader = std::fs::File::open(i.path()).unwrap();
        let res = nom_exif::parse_jpeg_exif(file_reader);
        let file_reader = std::fs::File::open(i.path()).unwrap();
        let res2 = nom_exif::parse_heif_exif(file_reader);
        println!("{} {}", res.is_ok(), res2.is_ok());
    }
thread 'main' panicked at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nom-exif-1.0.0/src/bbox.rs:192:25:
range start index 35736592 out of range for slice of length 4088
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::slice::index::slice_start_index_len_fail_rt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:52:5
   3: core::slice::index::slice_start_index_len_fail
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:40:9
   4: <core::ops::range::RangeFrom<usize> as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:480:13
   5: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/slice/index.rs:18:9
   6: nom_exif::bbox::travel_header
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nom-exif-1.0.0/src/bbox.rs:192:25
   7: nom_exif::bbox::get_ftyp
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nom-exif-1.0.0/src/bbox.rs:279:28
   8: nom_exif::heif::parse_heif_exif
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nom-exif-1.0.0/src/heif.rs:65:22
   9: untitled::main
             at ./src/main.rs:10:20
  10: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5

ramdisk.img.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.