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

fix(oiiotool): don't propagate unsupported channels #3838

Merged
merged 1 commit into from
May 14, 2023

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented May 14, 2023

Fixes #3837

oiiotool already attempted to trim extra channels when outputting to a format that can't support it. It correctly handled the two common cases:

  • More than 4 channels for formats that don't have supports("nchannels") will drop after the first 4 channels.
  • More than 3 channels for formats that don't have supports("alpha") will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file where the last channel is NOT alpha, and the output file supports an alpha channel but not arbitrary channels. A concrete example might be an input file that is exr with channels R, G, B, Z, writing to a PNG file (which can support RGB or RGBA). We wouldn't want to write what appears to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the alpha_channel and z_channel flags, which is important if the new channel lists drop one of those channels.

Fixes 3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common
cases:

* More than 4 channels for formats that don't have
  `supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
  will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be
an input file that is exr with channels R, G, B, Z, writing to a PNG
file (which can support RGB or RGBA). We wouldn't want to write what
appears to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new
channel lists drop one of those channels.
@lgritz lgritz merged commit dce61b3 into AcademySoftwareFoundation:master May 14, 2023
19 of 20 checks passed
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request May 15, 2023
…oundation#3838)

Fixes AcademySoftwareFoundation#3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common cases:

* More than 4 channels for formats that don't have
`supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be an
input file that is exr with channels R, G, B, Z, writing to a PNG file
(which can support RGB or RGBA). We wouldn't want to write what appears
to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new channel
lists drop one of those channels.
@lgritz lgritz deleted the lg-pngnonalpha branch May 15, 2023 22:19
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Jun 7, 2023
…oundation#3838)

Fixes AcademySoftwareFoundation#3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common cases:

* More than 4 channels for formats that don't have
`supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be an
input file that is exr with channels R, G, B, Z, writing to a PNG file
(which can support RGB or RGBA). We wouldn't want to write what appears
to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new channel
lists drop one of those channels.
lgritz added a commit to imageworks/OpenImageIO that referenced this pull request Jun 7, 2023
…oundation#3838)

Fixes AcademySoftwareFoundation#3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common cases:

* More than 4 channels for formats that don't have
`supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be an
input file that is exr with channels R, G, B, Z, writing to a PNG file
(which can support RGB or RGBA). We wouldn't want to write what appears
to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new channel
lists drop one of those channels.
birsoyo pushed a commit to birsoyo/oiio that referenced this pull request Jun 8, 2023
…oundation#3838)

Fixes AcademySoftwareFoundation#3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common cases:

* More than 4 channels for formats that don't have
`supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be an
input file that is exr with channels R, G, B, Z, writing to a PNG file
(which can support RGB or RGBA). We wouldn't want to write what appears
to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new channel
lists drop one of those channels.
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.

[BUG] oiiotool uses wrong channel for alpha when dropping channels
1 participant