Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extracting Exif data #182

Merged
merged 2 commits into from
Feb 16, 2021

Conversation

fseegraeber
Copy link
Contributor

Implements #42.

Also a first step towards image#1045.

Exposes Exif data as an Option<Vec<u8>> that can be parsed by client code e.g. using kamadak-exif (or simply to pass it on when saving the file again):

    let path = Path::new("tests")
        .join("reftest")
        .join("images")
        .join("ycck.jpg");

    let mut decoder = jpeg::Decoder::new(File::open(&path).unwrap());
    decoder.decode().unwrap();

    let exif_data = decoder.exif_data().unwrap();
    let exif_reader = exif::Reader::new();
    let exif = exif_reader.read_raw(exif_data).unwrap();
    for field in exif.fields() {
        println!("{}", field.display_value());
    }

Not 100% sure about the exif_data() method. Since Exif might contain up to 64kb a copy might be a bit much.
Perhaps:

pub fn take_exif_data(&mut self) -> Option<Vec<u8>> {
    self.exif_data.take()
}

or

pub fn exif_data(&self) -> Option<&Vec<u8>> {
    self.exif_data.as_ref()
}

I guess exif data might be inspected multiple times e.g. to determine orientation?

src/decoder.rs Outdated Show resolved Hide resolved
@HeroicKatora
Copy link
Member

I must have missed the force pushed commit addressing the review comment. @fseegraeber Pinging a maintainer when a PR is in limbo is absolutely encouraged 🙂

@fseegraeber
Copy link
Contributor Author

Will do! 😄

@fseegraeber fseegraeber deleted the exif-data branch February 16, 2021 23:09
wartmanm pushed a commit to wartmanm/jpeg-decoder that referenced this pull request Oct 4, 2021
Add support for extracting Exif data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants