Skip to content

Conversation

@kookiCT
Copy link
Contributor

@kookiCT kookiCT commented Sep 26, 2025

Fixes #4799

Description

When trimming an image that contains an empty subimage, the resulting ROI unexpectedly included the top-left pixel even if zero in all subimages.

To avoid this, empty ROIs are ignored when computing the overall non-zero region.
If all subimages are empty, the first subimage ROI is used and doctored to be 1 pixel.

Tests

Two tests have been added to the oiiotool testsuite:

  • 1 to check the trimming of an empty image
  • 1 to check the trimming of a non-empty image with an empty subimage

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.

Fixes AcademySoftwareFoundation#4799

When trimming an image that contains an empty subimage, the resulting
ROI unexpectedly included the top-left pixel even if zero in all
subimages.

To avoid this, empty ROIs are ignored when computing the overall
non-zero region.
If all subimages are empty, the first subimage ROI is used and doctored
to be 1 pixel.

Two tests have been added to the oiiotool testsuite:
 - 1 to check the trimming of an empty image
 - 1 to check the trimming of a non-empty image with an empty subimage

Signed-off-by: Carine Touraille <[email protected]>
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 26, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kookiCT / name: Carine Touraille (fe1313b)

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, thanks for the fix!

@lgritz lgritz merged commit d9442d2 into AcademySoftwareFoundation:main Sep 27, 2025
31 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Sep 27, 2025
…ion (AcademySoftwareFoundation#4909)

Fixes AcademySoftwareFoundation#4799

When trimming an image that contains an empty subimage, the resulting
ROI unexpectedly included the top-left pixel even if zero in all
subimages.

To avoid this, empty ROIs are ignored when computing the overall
non-zero region.
If all subimages are empty, the first subimage ROI is used and doctored
to be 1 pixel.

Two tests have been added to the oiiotool testsuite:
 - 1 to check the trimming of an empty image
 - 1 to check the trimming of a non-empty image with an empty subimage

Signed-off-by: Carine Touraille <[email protected]>
@lgritz lgritz added oiiotool oiiotool devdays25 DevDays 2025 project labels Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devdays25 DevDays 2025 project oiiotool oiiotool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] issue with --trim multipart images that has parts with zero pixels

2 participants