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

[FEATURE REQUEST] oiiotool command to split "layers" into subimages or separate images #4546

Open
lgritz opened this issue Nov 30, 2024 · 3 comments
Labels
difficulty/easy Hours-to-days for veterans, days for newcomers to the project feature request help wanted A task that is desired, but needs somebody to commit the effort to implement it. mackerel 🎣 Medium sized project that somebody should take on to dive deeper into being an OIIO developer. oiiotool oiiotool

Comments

@lgritz
Copy link
Collaborator

lgritz commented Nov 30, 2024

Just like we have oiiotool command --sisplit which splits an image's subimages (what exr calls "parts") into separate images on the oiiotool stack, it might be handy to have --layersplit (split channel-name-based layers into separate images on the stack) and/or --layertosi (split the layers in an image into an image organized by subimages/parts). In both cases, the layers would need to be deduced by looking at and grouping the channel names.

Background:

Modern (>= 2.0) OpenEXR has "multi-part" files that can contain a different raster image in each part (for example, a beauty pass, reflections, isolated lights, mattes, etc). The parts are read separately, efficiently. When dinosaurs were alive and used OpenEXR 1.x, the lack of multi-part led to a convention called "multi-layer" exr, in which a ton of channels were jammed into a (single part of a) single image, and channels were grouped simply according to a naming convention, for example "LAYERNAME.channelname", and all the channels with the same LAYERNAME were considered a "layer" or group that conceptually goes together.

Ideally, nobody would know or care about this for the last several years, because they'd be using parts instead. But there is some software out there still making "multi-layer exr files" where dozens of channels are jammed into a single part. So maybe we need the equivalent of --sisplit for layers? (Note: we can already group separate images into a single image with multiple "layers" by using the existing --chappend plus ensuring that the channels are named according to the layer naming conventions, so we don't need a new command for going in that direction.)

@lgritz lgritz added feature request help wanted A task that is desired, but needs somebody to commit the effort to implement it. mackerel 🎣 Medium sized project that somebody should take on to dive deeper into being an OIIO developer. oiiotool oiiotool difficulty/easy Hours-to-days for veterans, days for newcomers to the project labels Nov 30, 2024
@mugulmd
Copy link
Contributor

mugulmd commented Jan 8, 2025

Hey @lgritz, I can take a look at that !
Do you have some example images in mind for testing ? Or should I go on and find/make some on my own ?

@lgritz
Copy link
Collaborator Author

lgritz commented Jan 8, 2025

I don't, but it should be easy to construct one with oiiotool -- it's really just a matter of making a low-res image with a bunch of channels that have the right names to group them into "layers."

oiiotool -pattern constant:color=1,2,3,4,5,6,7,8,9,10 4x4 10 -chnames "R,G,B,A,diffuse.R,diffuse.G,diffuse.B,specular.R,specular.G,specular.B" -d half -o layers.exr

Then what we want is a new command like

oiiotool layers.exr --layersplit -o parts.exr

And then oiiotool --info -v -a --stats parts.exr should show that parts.exr has 3 parts, the first containing the original R,G,B,A channels, the second containing the three diffuse channels, and the third containing the three specular channels.

You can rely on the fact than when reading in the original multi-layer file, our exr reader will automatically reorder the channels (for apps using the OIIO API, not in the disk file itself) to group them by layer name. So you just need to walk the channel list and know that a new part starts any time the "pre-dot" part of the channel name changes, if you know what I mean.

@mugulmd
Copy link
Contributor

mugulmd commented Jan 9, 2025

Perfect, thanks for all the info 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/easy Hours-to-days for veterans, days for newcomers to the project feature request help wanted A task that is desired, but needs somebody to commit the effort to implement it. mackerel 🎣 Medium sized project that somebody should take on to dive deeper into being an OIIO developer. oiiotool oiiotool
Projects
None yet
Development

No branches or pull requests

2 participants