fix(thumb): don't write thumbnail_* metadata to formats that can't hold a thumbnail - #5357
Open
jinhgkim wants to merge 1 commit into
Open
fix(thumb): don't write thumbnail_* metadata to formats that can't hold a thumbnail#5357jinhgkim wants to merge 1 commit into
thumbnail_* metadata to formats that can't hold a thumbnail#5357jinhgkim wants to merge 1 commit into
Conversation
…hold a thumbnail Assisted-by: Claude Code / Opus 5 Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Noticed a thumbnail metadata leak in
iconvertwhen converting from a format that supports thumbnails to one that doesn't. Thethumbnail_*attributes ride along in the spec and get serialized, so the file claims a thumbnail it doesn't have.oiiotoolalready stripped these, so I moved the stripping intoImageOutput::check_open()where it covers every writer and caller.Also stopped
ImageBuftreating those attributes as proof a thumbnail exists. Both read paths now takem_has_thumbnailfromget_thumbnail()'s return. The ImageCache-backed path was ignoring the return entirely, so it and the direct path disagreed on the same file.Optional Read
One thought I had while working on this: currently we check whether a thumbnail exists by looking at its width and height in ImageBuf, which I think is unreliable.
rawinputeven hacks around this guard, sincetwidth/theightaren't always populated by libraw when the file does contain a thumbnail - something I only learned recently! I feel we need a more reliable guard: something like thensubimagesmechanism, but annthumbnails()we could check instead. That would break ABI though, so we could save it for 3.3. Just wanted to mention it so I don't forget.Tests
Added
test_thumbnail_attribs()that writes a spec claiming a thumbnail for every format that can't embed one and asserts it's absent on read back.Assisted-by: Claude Code / Opus 5
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.