Hey everyone,

I'm trying to write some code that will take the metadata from one exr, and
add/replace the metadata in the second exr in Python (Tested in oiio 1.5.18
and 1.6.14) . The issue I'm getting is when I run the code the first time
with a unique attribute, it fails to write the attribute. However, if I run
the same code a second time, the attribute is properly written. I have a
feeling the image data is not being properly sent to disk after write (but
instead, it is sent to disk after Python closes), and reading back returns
the old metadata.

Here's the example code I used:

import OpenImageIO as oiio

patha = "/path/to/image_a.exr"
pathb = "/path/to/image_b.exr"
attr = "attr1"


def a():
    # Set an attribute on the first image.
    bufa = oiio.ImageBuf(patha)
    spec = bufa.specmod()
    spec.attribute(attr, attr)
    bufa.write(patha)

    bufa = oiio.ImageBuf(patha)
    spec = bufa.spec()


def b():
    # Set the attribute on the second image.
    bufa = oiio.ImageBuf(patha)
    speca = bufa.spec()
    result = speca.get_string_attribute(attr)

    # Keeps on failing here, since the attribute is not set yet.
    assert result, "No attribute."

    bufb = oiio.ImageBuf(pathb)
    specb = bufb.specmod()
    specb.attribute(attr, result)
    bufb.write(pathb)


def c():
    # Print all of the attributes on the second file.
    bufb = oiio.ImageBuf(pathb)
    specb = bufb.spec()

    for attr in specb.extra_attribs:
        print attr.name, attr.value


if __name__ == '__main__':
    a()
    b()
    c()


Could it be that I'm doing something wrong, or is there something that I
can do to force the read after the write to read the new metadata? Thanks!

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

Reply via email to