Thank you Larry, that makes a lot of sense. I will stick with oiiotool in
that case, it will get the job done.

On Mon, Apr 9, 2018, 22:35 Larry Gritz, <l...@larrygritz.com> wrote:

> The easy way to do it from Python is to load it as an ImageBuf, use
> ImageBufAlgo.channels() to copy just the channels you want to a second
> ImageBuf, then save it. Basically:
>
>     inbuf = ImageBuf ("allchannels.exr")
>     outbuf = ImageBuf()
>     ImageBufAlgo.channels (outbuf, inbuf, ("R", "G", "B"))
>     outbuf.write ("justRGB.exr")
>
> I would expect that to be the same speed as oiiotool, since that's what's
> going on under the covers anyway (the oiiotool may still beat it, because
> it's pretty well tuned with all the options, has pretty good thread
> management, and no Python overhead at all).
>
> I think that basic path (read, IBA::channels(), write) is about the best
> you're going to do using only the OIIO APIs.
>
> There are ways (in the underlying libIlmImf, but not exposed by OIIO) that
> you can read uncompressed chunks, but if what you're after is to extract
> only certain channels, the data for those channels are scattered around
> variously within the compressed block. So I don't see how you could do it
> without uncompressing the whole chunk, copying out the individual channels
> you want, and then re-compressing. Which is basically what
> oiiotool/channels() is doing. I doubt you could make it substantially
> faster without getting extremely clever and low level with your own
> compression code.
>
> -- lg
>
>
> On Apr 9, 2018, at 4:35 PM, Yegor Swarovski <yego...@gmail.com> wrote:
>
> Hello, just a simple question - I want to use OpenImageIO to open an image
> file, strip out all but a few channels, and save it again. I have found how
> to do this with oiiotool's -ch flag but I am curious to try this with the
> OpenImageIO in python and see if that has some faster performance.
>
> My question is whether this is possible to do without touching any actual
> pixel data - I am not sure how EXRs are stored or compress data so I am not
> sure if it is possible to simply open an ImageInput or ImageBuf, delete
> some channels, and save it again, or if I will need to start copying
> pixels/image data to a second ImageBuf.
>
> Thanks!
>
>
> --
> Larry Gritz
> l...@larrygritz.com
>
>
>
>
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to