Hi Larry, thanks a bunch for your help. I tried the code you sent me which attempts to read the colorspace of the input image and the result is a now a brighter and desaturated image. I uploaded the tiff image I’m using as a source so hopefully you can see the same result on your end.
[cid:[email protected]] Test Tiff image: http://s000.tinyupload.com/?file_id=10327734964867955756<http://s000.tinyupload.com/index.php?file_id=10327734964867955756> Updated Code Sample: import sys from OpenImageIO import OpenImageIO as oiio from OpenImageIO import ImageBufAlgo, ImageBuf, ImageSpec, ImageInput sourcePath = "C:/temp/ataafm_diff_v001.1005.tif" destImgPath = "C:/temp/test_oiio.jpg" sourceImg = ImageInput.open(sourcePath) spec = sourceImg.spec() pixels = sourceImg.read_image(0, 3, oiio.UINT8) sourceBufSpec = ImageSpec(spec.width, spec.height, 3, oiio.UINT8) sourceBuf = ImageBuf(sourceBufSpec) sourceBuf.set_pixels(oiio.ROI.All, pixels) resizedImgSpec = ImageSpec(int(120), int(120), 3, oiio.UINT8) resizedBuf = ImageBuf(resizedImgSpec) ImageBufAlgo.resample(resizedBuf, sourceBuf) # Set input colorspace to linear if converting EXR file if sourcePath.split('.')[-1] == 'exr': ImageBufAlgo.colorconvert(resizedBuf, resizedBuf, 'linear', 'sRGB') if destImgPath.split('.')[-1] == 'jpg': # query input color space, presume linear if there is no such metadata srcColSpace = sourceImg.spec().get_string_attribute('oiio:ColorSpace', 'linear') ImageBufAlgo.colorconvert(resizedBuf, resizedBuf, srcColSpace, 'sRGB') resizedBuf.write(destImgPath) From: Renaud Talon Sent: Friday, December 28, 2018 1:10 PM To: 'Larry Gritz' <[email protected]>; OpenImageIO developers <[email protected]>; [email protected] Subject: RE: [Oiio-dev] Tiff image conversion to jpg color shift issue oiiotool.exe C:\temp\ataafm_diff_v001.1005.tif -resize 120x120 -o c:/temp/test_oiio_tool.jpg From: Larry Gritz <[email protected]<mailto:[email protected]>> Sent: Friday, December 28, 2018 1:05 PM To: OpenImageIO developers <[email protected]<mailto:[email protected]>>; Renaud Talon <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> Subject: Re: [Oiio-dev] Tiff image conversion to jpg color shift issue What oiiotool command line did you use when it worked as expected? On December 28, 2018 12:36:04 PM PST, Renaud Talon <[email protected]<mailto:[email protected]>> wrote: Hi Larry, I’m having a problem when making thumbnails from tiff images where the results image is coming out darker and less saturated than the source. When using oiiotool.exe it results in a proper output but the issue happens when I do the conversion myself from the python API. Any idea why this is happening ? Thanks ! Trimmed down code: from OpenImageIO import OpenImageIO as oiio from OpenImageIO.OpenImageIO import ImageBufAlgo, ImageBuf, ImageSpec, ImageInput sourceImgPath = "C:/temp/ataafm_diff_v001.1005.tif" sourceImg = ImageInput.open(sourceImgPath) spec = sourceImg.spec() pixels = sourceImg.read_image(0, 3, oiio.UINT8) sourceBufSpec = ImageSpec(spec.width, spec.height, 3, oiio.UINT8) sourceBuf = ImageBuf(sourceBufSpec) sourceBuf.set_pixels(oiio.ROI.All, pixels) resizedImgSpec = ImageSpec(int(120), int(120), 3, oiio.UINT8) resizedBuf = ImageBuf(resizedImgSpec) ImageBufAlgo.resample(resizedBuf, sourceBuf) # Set input colorspace to linear if converting EXR file if sourceImgPath.split('.')[-1] == 'exr': ImageBufAlgo.colorconvert(resizedBuf, resizedBuf, 'linear', 'sRGB') resizedBuf.write('C:/temp/test_oiio.jpg') [cid:[email protected]] Renaud -- Larry Gritz [email protected]<mailto:[email protected]>
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
