oiiotool: Add --nchannels flag for parity with maketx#5198
Merged
lgritz merged 1 commit intoMay 15, 2026
Conversation
|
|
06ca836 to
b0fa3fb
Compare
Signed-off-by: Danny Greenstein <danny.gr@gmail.com>
b0fa3fb to
a418ed9
Compare
Collaborator
|
This LGTM, Danny, but it's marked as draft. Are you still working on it? |
Contributor
Author
|
lgritz
approved these changes
May 15, 2026
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
This PR adds a
--nchannelsflag to oiiotool, providing parity with the existing flag in maketx.Problem:
When processing images from varied sources in automated pipelines, using name-based channel selection (e.g., --ch R,G,B) is fragile. If an input image uses non-standard names (e.g., X,Y,Z or 1,2,3), the command may output black channels or issue warnings that are easily missed in large logs.
Solution:
While you can solve this by specifiying the indices of the channnels, e.g --ch 0,1,2, the
--nchannelsflag offers a more intuitive and robust "shortcut" to force an image to a specific channel count. maketx has had one for years and I found that it works really well and often wished oiiotool would have one too.Implementation:
The implementation acts as a wrapper around action_channels, programmatically generating the index string. It uses ustring to intern the generated string, ensuring memory safety even if the action execution is deferred/postponed.
Assisted-by: Google Gemini (advice on ustring interning and architectural structure).
Tests
I added some tests to showcase what this is trying to solve
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
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.