Hi Hugh!

You should be able to do this with ImageBufAlgo.channels() (
https://openimageio.readthedocs.io/en/latest/pythonbindings.html#image-transformations-and-data-movement
)

import OpenImageIO as oiio

buf = oiio.ImageBuf('/path/to/source.exr')
new_buf = oiio.ImageBufAlgo.channels(buf, ('R', 'R', 'R'), ('R', 'G', 'B'))
new_buf.write('/path/to/all_red.exr')


On Mon, Aug 8, 2022 at 6:47 PM Hugh Macdonald <
hugh.macdon...@scanlinevfx.com> wrote:

> Hey all,
>
>
> I'm not overly familiar with the OIIO python API, so apologies if this
> is quite a simple question! I can't find any information online on how
> to do this with the Python API...
>
> I've got 2 EXRs, both with RGB channels, and I'd like to take the R
> channel from one of them and put it into another channel in the other.
>
> I've been looking at doing a 2-step process. The first step being to
> rename the channels in one ImageBuf, and to remove the unneeded
> channels, and the second being to use ImageBufAlgo.channel_append() to
> combine the two images together.
>
>
> This feels like it is unnecessarily 2 steps. Could someone point me at
> some examples for how to do this in a single step?
>
>
> I'm sure that this is pretty simple, but all the examples that I can
> find are for how to do this kind of thing using oiiotool, rather than
> doing it directly using the API.
>
>
> Thanks
>
> --
> Hugh
>
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>


-- 
-Daniel
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to