I'm not quite sure I understand what you're getting at.

For example, can you modify the script I posted a couple messages back to try 
to do what you want, so I can better understand what you're trying to do?

        -- lg


> On Feb 22, 2022, at 8:07 AM, Jerome Raim <[email protected]> wrote:
> 
> Thank you so much, very helpful. Hopefully the last question regarding this. 
> In my actual script I'm iterating through all the external matte channels, 
> seeing if their names collide and giving them new names in case they do.
> 
> I was hoping to first create an empty image buf where the image spec has a 
> not-yet-known number of channels. So I was trying to just add a ROI and half 
> float format, but I was unable to write the subimage with the image spec 
> having zero channels (even though I'm adding channels shortly thereafter).
> 
> My workaround right now is to:
>     matte_buf = ImageBuf(comp.spec())
>     matte_buf = ImageBufAlgo.channels (matte_buf, (0,))
> 
> add all the matte channels and at the very end remove that first channel:
> matte_buf = ImageBufAlgo.channels (matte_buf, 
> tuple((matte_buf.spec().channelnames[1:])))
> 
> Is there a more elegant solution?
> 
> 
> 
> On Tue, Feb 22, 2022 at 2:35 AM Larry Gritz <[email protected] 
> <mailto:[email protected]>> wrote:
> On Feb 21, 2022, at 3:22 PM, Jerome Raim <[email protected] 
> <mailto:[email protected]>> wrote:
>> 
>> Larry, would you mind terribly boiler-plating some Python code on to create 
>> a single EXR with subimage 0 is RGB and subimage 1 is 
>> matte01,matte02,matte03,matte04 (ie combining the channels of the 2 matte 
>> EXRs).
> 
> In your original email, you said: out_filepath = '/tmp/exr.rexr'  
> "rexr" isn't a known extension, and that definitely will cause problems. But 
> I don't know if that was related to your real issues, or if it was just a 
> typo in your email.
> 
> But in any case, the following python script does what you asked:
> 
> 
> #!/usr/bin/env python3
> 
> import OpenImageIO as oiio
> 
> comp_buf = oiio.ImageBuf("comp-test02-roiMisMatch.exr")
> matte_buf = oiio.ImageBuf("matte-test02-roiMisMatch.exr")
> matte2_buf = oiio.ImageBuf("matte2-test02-roiMisMatch.exr")
> 
> combined_matte_buf = oiio.ImageBufAlgo.channel_append(matte_buf, matte2_buf)
> 
> out_filepath = 'exr.exr'
> 
> out = oiio.ImageOutput.create (out_filepath)
> if out is None :
>     print ("Could not create output file: ", oiio.geterror())
>     exit(1)
> 
> out.open(out_filepath, (comp_buf.spec(), combined_matte_buf.spec()))
> comp_buf.write(out)
> out.open(out_filepath, combined_matte_buf.spec(), "AppendSubimage")
> combined_matte_buf.write(out)
>      
> out.close()
> 
> 
> --
> Larry Gritz
> [email protected] <mailto:[email protected]>
> 
> 
> 
> 
> _______________________________________________
> Oiio-dev mailing list
> [email protected] <mailto:[email protected]>
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
[email protected]




_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to