Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oiiotool): oiiotool --layersplit, new command to split layers #4591

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

mugulmd
Copy link
Contributor

@mugulmd mugulmd commented Jan 13, 2025

Description

Implement FR from #4546

Add a new --layersplit command to oiiotool to split an image into its channel-name-based layers onto the stack.

The extracted layer names are then stored in the oiio:subimagename metadata (in case it is needed for later use, e.g merging these "layers" as sub-images), and the extracted channel names replace the old channel names in the new images.

Example:
an image with channels R, G, B, A, diffuse.R, diffuse.G, diffuse.B will be split into two images, the first one with channels R, G, B, A and the second one named diffuse with channels R, G, B.

Note: we did not implement the --layertosi command suggested in the FR as it can already be done with a combination of --layersplit and --siappendall

Tests

We add a test in the test suite that takes a "multi-layer" image, splits the layers and merges them as sub-images. The final image should have 3 sub-images.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

src/oiiotool/oiiotool.cpp Outdated Show resolved Hide resolved
@mugulmd mugulmd changed the title [WIP] oiiotool: new command to split layers oiiotool: new command to split layers Jan 15, 2025
@mugulmd mugulmd marked this pull request as ready for review January 15, 2025 22:15
@mugulmd mugulmd requested a review from lgritz January 16, 2025 18:03
@lgritz
Copy link
Collaborator

lgritz commented Jan 18, 2025

Closes #4546

src/doc/oiiotool.rst Outdated Show resolved Hide resolved
src/doc/oiiotool.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM, great job!

On the docs, I made one spelling and phrasing suggestion, as well as a question/suggestion aimed at clarifying what happens to channels that aren't part of a named layer. That's about all I can think of to make this PR better, it's really great.

Breaking out an entirely new test for this as you did is fine, though I wanted to let you know (in case you're inclined to change it) that it would have also been ok to add one more command line to an existing test, whichever of the oiiotool related tests looked like it contained the most related commands (maybe wherever the tests for --siappend and --sisplit are, so that related commands have their tests together).

@lgritz
Copy link
Collaborator

lgritz commented Jan 18, 2025

One more FYI: When mentioning an issue in a PR, GitHub expects you to use a particular phrasing in order to truly link them in such a way that accepting the PR will automatically close the issue:

Closes #xxx

or

Fixes #xxx

Anything else is just talk, and doesn't really link the issue.

@lgritz lgritz changed the title oiiotool: new command to split layers feat(oiiotool): oiiotool --layersplit, new command to split layers Jan 18, 2025
@lgritz lgritz added enhancement Improvement of existing/working features. feature request oiiotool oiiotool labels Jan 18, 2025
@mugulmd
Copy link
Contributor Author

mugulmd commented Jan 21, 2025

Hey @lgritz
Thanks for the review (and all the tips on how the repo works, super helpful !), I think the code should be ready to go now :)

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lgritz lgritz merged commit 2677d4c into AcademySoftwareFoundation:main Jan 22, 2025
28 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Jan 26, 2025
…cademySoftwareFoundation#4591)

Implement FR from AcademySoftwareFoundation#4546

Add a new `--layersplit` command to `oiiotool` to split an image into
its channel-name-based layers onto the stack.

The extracted layer names are then stored in the `oiio:subimagename`
metadata (in case it is needed for later use, e.g merging these "layers"
as sub-images), and the extracted channel names replace the old channel
names in the new images.

Example:
an image with channels `R, G, B, A, diffuse.R, diffuse.G, diffuse.B`
will be split into two images, the first one with channels `R, G, B, A`
and the second one named `diffuse` with channels `R, G, B`.

> Note: we did not implement the `--layertosi` command suggested in the
FR as it can already be done with a combination of `--layersplit` and
`--siappendall`

We add a test in the test suite that takes a "multi-layer" image, splits
the layers and merges them as sub-images. The final image should have 3
sub-images.

---------

Signed-off-by: Loïc Vital <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing/working features. feature request oiiotool oiiotool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants