I'm trying to convert a bunch of 32bit OpenExr files to 8 bit tifs.
For the conversion process, I used the python recipes provided in the oiio documentation.
The conversion from exr to tif worked fine, but I get nothing if I add in the bit rate that I wanted as a parameter (exactly following the python formula from documentation)
I then later tried just converting the file formats first, then using the ImageBufAlgo.colorconvert but I just get thrown a lot of error messages instead.
What I wanted to do was just turn the 32bit image and reduce it to 8bit with the correct gamma setting.
First I tried
python
image = 'C/.../image.exr' # grabbing file from network
buf = oiio.ImageBuf(image)
buf.write(texture_directory + 'outImage.tif', "uint8")
This didn't work at all. The code ran, but there was no images in the directory I specified.
Then I changed it to
python
image = 'C/.../image.exr' # grabbing file from network
buf = oiio.ImageBuf(image)
buf.write(texture_directory + 'outImage.tif')
And this worked! I had the images, except they are all 32bit files, which I need to change to 8bit.
So I thought I would try looping over the new tif images and then doing the color conversion in seperate steps. I tested out just one image to see if I could even get the colorconvert function working.
python
new_buf = oiio.ImageBuf('outImage.tif')
dst = oiio.ImageBufAlgo.colorconvert(new_buf, "sRGB", "linear")
Exactly as the documentation had it. Instead what I got was a bunch of error messages that weren't too dis-similiar to the ones I had been getting in the extract pixel color problem I had yesterday initially
Error: Python argument types in
# ImageBufAlgo.colorconvert(ImageBuf, str, str)
# did not match C++ signature:
# colorconvert(class OpenImageIO::v1_5::ImageBuf {lvalue} dst, class OpenImageIO::v1_5::ImageBuf src, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > from, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > to, bool unpremult=False, struct OpenImageIO::v1_5::ROI roi=<OpenImageIO.OpenImageIO.ROI object at 0x00000257C97A6348>, int nthreads=0)
# Traceback (most recent call last):
# File "<maya console>", line 27, in <module>
# ArgumentError: Python argument types in
# ImageBufAlgo.colorconvert(ImageBuf, str, str)
# did not match C++ signature:
# colorconvert(class OpenImageIO::v1_5::ImageBuf {lvalue} dst, class OpenImageIO::v1_5::ImageBuf src, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > from, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > to, bool unpremult=False, struct OpenImageIO::v1_5::ROI roi=<OpenImageIO.OpenImageIO.ROI object at 0x00000257C97A6348>, int nthreads=0) #
Would really appreciate any help and explanation as to what I'm not getting.
Edit: I'm adding the 1.7 code I tried following Larry's reply:
src = ImageBuf(filename)
dst = ImageBuf()
result_bool = ImageBufAlgo.colorconvert (dst, src, 'sRGB', 'linear')
The error message I got is this:
# Error: Python argument types in
# ImageBufAlgo.__init__(ImageBufAlgo, ImageBuf, ImageBuf, str, str)
# did not match C++ signature:
# __init__(struct _object * __ptr64)
# Traceback (most recent call last):
# File "<maya console>", line 32, in <module>
# ArgumentError: Python argument types in
# ImageBufAlgo.__init__(ImageBufAlgo, ImageBuf, ImageBuf, str, str)
# did not match C++ signature:
# __init__(struct _object * __ptr64) #