Hello,

I am trying to open and save a PNG that contains RGB values that are not
associated with the A (or non-premultiplied) with OIIO and Python. I am
trying the following code to tell OIIO ImageBuf to read unassociated, but
it appears that it isn't respecting it. I'm restricted to OIIO 1.5.x due to
the only builds on Windows that I found with Python being from
www.lfd.uci.edu/~gohlke/pythonlibs/#openimageio. Am I doing something
wrong, or would I have to use ImageInput -> ImageBuf? If so, is there any
way to convert the ImageInput to ImageBuf without doing
ImageBuf.setpixel(x, y, z, pixel)?

Thanks in advanced!

# The code
import OpenImageIO as oiio

if __name__ == '__main__':
src = "c:/temp/blah/src.png"
dst = "c:/temp/blah/dst.png"

config = oiio.ImageSpec()
# Wasn't 100% sure what the attribute should be, so trying all possible
ones. :)
config.attribute("oiio:UnassociatedAlpha", 1)
config.attribute("oiio:unassociatedalpha", 1)
config.attribute("UnassociatedAlpha", 1)
config.attribute("unassociatedalpha", 1)
buf = oiio.ImageBuf(src)
# Read the file with the config
buf.reset(src, 0, 0, config)
# Write to a new png
buf.write(dst)
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to