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

Exif support #221

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Exif support #221

wants to merge 5 commits into from

Conversation

seaeagle1
Copy link

Curious whether this is (or can be turned into) something usable for more than just me.

I've added a way to access embedded Exif tags in a sort-of-standardized way. The basic idea is that allows access when decoding images for other parsing libraries and for recoding images with the Exif tag intact. Since Exif is essentially TIFF-formatted, all the basic tools were more or less in place and I just had to tweak them a bit. The things that were really missing was support for IFD sub-directories and encoding values with a dynamically derived type.

Decoder -> has a method to gather the Exif information, store the entries and feed them into an encoder for a TIFF-file without pixel data.

Encoder -> has a similar method to decode TIFF-file with-or-without pixel data and feed the Exif entries into the encoder itself.

@fintelia
Copy link
Contributor

Thanks for sharing this!

I've been wanting to add better EXIF handling to image-rs and being able to convert the EXIF data in a TIFF file into the same form as the EXIF chunks in PNG or JPEG would certainly help with that. It'll probably be a little while before I have a chance to work on implementing that, so I'll leave this open for now

@spoutn1k
Copy link
Contributor

spoutn1k commented Aug 6, 2024

Where is this at ? I am interested in writing Exif as well and would love to help.

@spoutn1k
Copy link
Contributor

IFD data structures are defined twice. In encoder:

ifd: BTreeMap<u16, DirectoryEntry<K::OffsetType>>,

struct DirectoryEntry<S> {
data_type: u16,
count: S,
data: Vec<u8>,
}

And decoder:

pub type Directory = HashMap<Tag, Entry>;

pub struct Entry {
type_: Type,
count: u64,
offset: [u8; 8],
}

u16 can be subsituted for Tag or Type in the above. Why not create a ImaegFileDirectory object that contains the data in a cow to keep the possibility of having references and implementing methods to manipulate the IFD on it ?

@spoutn1k
Copy link
Contributor

Does this require an image-exif crate to be used in more than tiff ?

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.

3 participants