Skip to content

oiiotool: Add --nchannels flag for parity with maketx#5198

Merged
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
grdanny:oiiotool_nchannels
May 15, 2026
Merged

oiiotool: Add --nchannels flag for parity with maketx#5198
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
grdanny:oiiotool_nchannels

Conversation

@grdanny
Copy link
Copy Markdown
Contributor

@grdanny grdanny commented May 15, 2026

Description

This PR adds a --nchannels flag 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 --nchannels flag 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:

  • 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
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 15, 2026

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

  • ✅ login: grdanny / name: Danny Greenstein (a418ed9)

@grdanny grdanny force-pushed the oiiotool_nchannels branch from 06ca836 to b0fa3fb Compare May 15, 2026 04:40
Signed-off-by: Danny Greenstein <danny.gr@gmail.com>
@grdanny grdanny force-pushed the oiiotool_nchannels branch from b0fa3fb to a418ed9 Compare May 15, 2026 04:42
@grdanny grdanny added the devdays26 Dev Days 2026 label May 15, 2026
@lgritz lgritz added the oiiotool oiiotool label May 15, 2026
@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented May 15, 2026

This LGTM, Danny, but it's marked as draft. Are you still working on it?

@grdanny grdanny marked this pull request as ready for review May 15, 2026 06:34
@grdanny
Copy link
Copy Markdown
Contributor Author

grdanny commented May 15, 2026

This LGTM, Danny, but it's marked as draft. Are you still working on it?
Thank you!
Was just waitng for the CI to pass

@lgritz lgritz merged commit a6fd93a into AcademySoftwareFoundation:main May 15, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devdays26 Dev Days 2026 oiiotool oiiotool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants