mindeng / nom-exif

Exif/metadata parsing library written in pure Rust, both image (jpeg/heif/heic/jpg/tiff etc.) and video/audio (mov/mp4/3gp/webm/mkv/mka, etc.) files are supported.
https://crates.io/crates/nom-exif
MIT License
43 stars 6 forks source link

Library cannot read file, that exiftool reads properly #2

Closed qarmin closed 2 months ago

qarmin commented 7 months ago
        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
mindeng commented 7 months ago

This JPG file appears to be corrupted, so returning this error is expected. I made some minor improvements to the error message in version 1.0.1. You can try again. If you encounter any other issues, please don't hesitate to let me know. Thank you!

qarmin commented 7 months ago

Is it possible to ignore the errors and return the exif data that was extracted correctly?

mindeng commented 2 months ago

Sorry for replying so late, I will reopen this issue and try to improve it. Thank you for your feedback!

mindeng commented 2 months ago

@qarmin @xandkar This problem has been completely solved!

The reason for this problem is that when parsing IFD, as long as one of the DirectoryEntry fails to parse, it will stop parsing and report an error. The new implementation will ignore the errors encountered during parsing of DirectoryEntry, and continue trying to parse subsequent data.

If you are interested in the implementation details, you can refer to this commit.

If you encounter other problems, please feel free to submit a bug, thank you!