Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementexif_metadata for TIFF#2613

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
1c3t3a wants to merge1 commit intoimage-rs:main
base:main
Choose a base branch
Loading
from1c3t3a:tiff-exif

Conversation

@1c3t3a
Copy link
Contributor

Exif metadata for TIFF is funny, as the Tiff file itself is stored in the exif directory structure. So the trivial answer to what is Exif metadata is just the bytes of the file itself.

Note: This is not the most efficient way of obtaining the metadata as it also copies the image bytes, which we technically don't need. The alternative here is to add this to the tiff create and copy the correct metadata sections together. We didn't pursue this route as there were ideas to rework the entiretiff::Value type and this would likely add a huge dependency on the current behavior. We're open for feedback if we should to go down that route, though.

hanneskaeufler reacted with hooray emoji
Exif metadata for TIFF is funny, as the Tiff file itself is stored in the exifdirectory structure. So the trivial answer to what is Exif metadata is just thebytes of the file itself...Co-authored-by: Rasmus Piorr <piorr@google.com>
@Shnatsel
Copy link
Member

I'm not a fan of this approach because if the application handles Exif like a black box and forwards it to the output (like most image conversion programs would do, including my ownwondermagick) then this approach would embed the entire TIFF image into the converted image as metadata, resulting in extreme bloat.

@1c3t3a
Copy link
ContributorAuthor

then this approach would embed the entire TIFF image into the converted image as metadata, resulting in extreme bloat.

Thanks for the feedback, that makes sense! I think the alternative for sure results in less pixel data, but is also annoying for the image crate:

  1. We can read all IFD tags that are notStripOffsets orTileOffsets.
  2. We reencode them to Exif using e.g. kamadak-exif.
  3. We return those bytes.

This will result in smaller exif blocks for sure, but currently has the problem that we cannot really write exif blocks easily in Rust. The only thing I found is the experimental Writer in kamadak-exif:https://docs.rs/kamadak-exif/0.6.1/exif/experimental/struct.Writer.html.

@197g
Copy link
Member

Writing exif is the same as writingtiff IFDs with a different but overlapping set of keys (u16) used in the kv-map. Several documents gives us an almost exhaustive list of tags and their values which should be used for Exif, GPS, camera specific, private tags. In regards other than missing well-defined expected types all of these behave the same as the tiff structure itself.

We have a choice here:

  1. For comprehensive support: Then we need to offer the complete file. Unfortunately, some rather ill-conceived vendor extensions used an obscured IFD pointer, that is byte data that denotes an offset but that we do not rewrite into its new offset if we copy it over.
  2. For a correct lower-bound support: We can iterate the IFD structure with the methodstiff offers and copy them over into a new file. Now,tiff::encoder::TiffEncoder is still a bit rough and does not expose all the methods that you'd want, notably missing a method of adding a rawEntry structure with another backingRead /IfdDecoder<'_> for the data. It's also complex to add a subdirectory. Sokamadak-exif might be the most convenient for now.
  3. Maybe I'm overlooking a middle ground, maybe my interpretation of vendor extensions isn't quite up to date?https://exiftool.org/TagNames/EXIF.html is somewhat detailed but not machine readable and includes explicit unknown items

I tend towards (2). Currently, inimage we only read the first of a tiff's chain of images so that returning all the metadata is even misleading. I also concur that the overhead is just too high for most expected uses. If we returned a more complexExif type, notVec<u8>, then maybe it would be more justified but this is a pitfall if you're handling images without looking at their format.

fintelia reacted with thumbs up emoji

@1c3t3a
Copy link
ContributorAuthor

Yeah I agree and thanks for the summary@197g! Then let me take a stab at (2). Would it be fine to add a dependency on kamadak-exif and its experimentalWriter for now until theTiffEncoder is ready?

@197g
Copy link
Member

197g commentedNov 5, 2025
edited
Loading

Definitely for sketch purposes and it is lightweight enough. The unsafe dependency needs some muster, I wonder what it is for. But should not hold up the implementation in principle as it does not leak immediately to the API as far as I can tell.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@1c3t3a@Shnatsel@197g

[8]ページ先頭

©2009-2025 Movatter.jp