Skip to content

feat(oiiotool): Add thumbnail get/set commands and fix TGA thumbnail I/O#5236

Open
jinhgkim wants to merge 8 commits into
AcademySoftwareFoundation:mainfrom
jinhgkim:oiiotool-thumbnail
Open

feat(oiiotool): Add thumbnail get/set commands and fix TGA thumbnail I/O#5236
jinhgkim wants to merge 8 commits into
AcademySoftwareFoundation:mainfrom
jinhgkim:oiiotool-thumbnail

Conversation

@jinhgkim

Copy link
Copy Markdown

Description

Adds oiiotool commands to extract and attach embedded thumbnails, and fixes TGA postage-stamp read/write bugs they exposed. This PR adresses #4889.

Note that thumbnail support is uneven across formats: get_thumbnail is implemented for PSD, camera RAW, and TGA, but set_thumbnail only for TGA. So you can read thumbnails from several formats, yet TGA is the only format that writes an embedded thumbnail today. e.g., input.exr ... --set-thumbnail -o out.exr silently produces an EXR with no embedded thumbnail.

  • Features:

    • oiiotool: add --get-thumbnail
    • oiiotool: add -i:get_thumbnail=1
    • oiiotool: add --set-thumbnail
  • Fixes:

    • targa thumbnail write: encode thumbnail like the main image (bottom-up, deassociated alpha, BGR(A))
    • targa thumbnail read: apply associateAlpha()

Assisted-by: Claude Code / opus-4.8

Tests

New tests in oiiotool-get-thumbnail, oiiotool-set-thumbnail, imagebuf_test

Checklist:

  • I have read the guidelines on contributions and code review procedures.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • I have updated the documentation if my PR adds features or changes
    behavior.
  • I am sure that this PR's changes are tested in the testsuite.
  • I have run and passed the testsuite in CI before submitting the
    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.)
  • My code follows the prevailing code style of this project and I
    fixed any problems reported by the clang-format CI test.
  • If I added or modified a public C++ API call, I have also amended the
    corresponding Python bindings. If altering ImageBufAlgo functions, I also
    exposed the new functionality as oiiotool options.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 15, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

jinhgkim added 7 commits June 14, 2026 22:42
Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
Encode the embedded thumbnail the same way as the main image: bottom-up
scanlines, deassociated alpha, and BGR(A) channel order. The original
implementation rather dumped the raw in-memory buffer, which left the
thumbnail flipped, R/B-swapped, and premultiplied.

Also clamp an oversized thumbnail to 255 rather than 256: each postage-stamp
dimension is a single byte, so 256 wrapped to 0 and the thumbnail was
silently dropped on read.

Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
TGA stores unassociated alpha, but OIIO keeps it associated in memory.
`readimg()` converts on read; `get_thumbnail()` did not, so RGBA thumbnails came
back too bright. Apply the same `associateAlpha()` conversion to the thumbnail.

get_thumbnail() is moved below associateAlpha() so it can call it without a
forward declaration.

Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
Assisted-by: Claude Code / opus-4.8
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
@jinhgkim jinhgkim force-pushed the oiiotool-thumbnail branch from 54e6a14 to 2b002d9 Compare June 15, 2026 05:42
Signed-off-by: Jinnie Kim <jinhgkim@gmail.com>
@jinhgkim jinhgkim force-pushed the oiiotool-thumbnail branch from 2b002d9 to c589b11 Compare June 15, 2026 05:44
@jinhgkim

jinhgkim commented Jun 15, 2026

Copy link
Copy Markdown
Author

During the CI run, a TGA thumbnail test failed because I added associateAlpha() logic in this branch. My reasoning is that if we apply associateAlpha() in TGAInput::readimg(), we should apply the same operation when reading thumbnails.

Let me know what you think.

Also, fyi, I have broken down the commits into logical steps with some details in the commit message.

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.

1 participant