I'm trying to resize an image after doing some additional processing using OpenImageIO and python. However it appears this process not is as easy as PIL. In PIL i can supply a new resolution for example 512 x 512 and it will resize my image regardless of it's current pixel aspect and resize it to fit it's maximum length so it fits inside a 512x512 box. How can i do this using OpenImageIO?
Currently this will just stretch the image to fit withint 512x512.
So images that favor width should fit based on the width value:
Whereas images that favor height should fit based on the height value:
buf = oiio.ImageBuf(file)
data = buf.spec()
print data.width
print data.height
resized = oiio.ImageBuf(oiio.ImageSpec (512, 512, 3, oiio.FLOAT))
oiio.ImageBufAlgo.resize(resized, buf, roi=oiio.ROI.All, nthreads=4)
resized.write(output)