Search code examples
pythonopenexropenimageio

Trying to extract a subimage using python and openimageIO fails


I just getting into writing stuff using OpenImageIO. I my experiment, I'm trying to extract a few select sub images from an exr file and write them into another one. But when I try the following examples from the documentation and I keep getting an error.

#!/usr/bin/env python

import OpenImageIO as oiio

filename = "a.exr"
final = "b.exr"

input = oiio.ImageInput.open (filename)
spec = input.spec ()
pixels = input.read_image ()
input.close ()

output = oiio.ImageOutput.create (final)
if output.supports("multiimage") :
    output.open(final, spec)
    output.write_image(pixels)
    output.close ()

When I try this, I get the following error :

ArgumentError: Python argument types in
    ImageOutput.open(ImageOutput, str, ImageSpec)
did not match C++ signature:
    open(PyOpenImageIO::ImageOutputWrap {lvalue}, std::string, boost::python::tuple {lvalue})
    open(PyOpenImageIO::ImageOutputWrap {lvalue}, std::string, OpenImageIO::v1_6::ImageSpec, OpenImageIO::v1_6::ImageOutput::OpenMode)

I was wondering if anyone can please point out what I'm doing wrong here? Any help is very much appreciated.

Thanks a lot


Solution

  • Do you know which version specifically you are using?

    It's some flavor of 1.6. That's from years ago. The current supported release is 2.0. Is it at all possible for you to use a modern version? Whatever trouble you're running into may be a long-ago-solved problem.