print('Open openlut.py and scroll down to the end to see the code that\'s working!')
#Open any format image. Try it with exr/dpx/anything!
img=ColMap.open(inPath+'/rock.exr')#Opens a test image 'test.exr', creating a ColMap object, automatically using the best image backend available to load the image at the correct bit depth.
'''
gammahasgammafunctionslikegamma.sRGB,calledbyvaluelikegamma.sRGB(val).Alltakeoneargument,thevalue(x),andreturnsthetransformedvalue.Colordoesn't matter for gamma.
gFunc=Func(gamma.sRGBinv)#A Func Transform object using the sRGB-->Linear gamma formula. Apply to ColMaps!
gFuncManualsRGB=Func(lambdaval:((val+0.055)/1.055)**2.4ifval>0.04045elseval/12.92)#It's generic - specify any gamma function, even inline with a lambda!
#LUT from Function: sRGB --> Linear
oLut=LUT.lutFunc(gamma.sRGBinv)#A LUT Transform object, created from a gamma function. Size is 16384 by default. LUTs are faster!
oLut.save(path+'/sRGB-->Lin.cube')#Saves the LUT to a format inferred from the extension. cube only for now!
#Opening LUTs from .cube files.
lut=LUT.open(path+'/sRGB-->Lin.cube')#Opens the lut we just made into a different LUT object.
lut.resized(17).save(path+'/sRGB-->Lin_tiny.cube')#Resizes the LUT, then saves it again to a much smaller file!
#Matrix Transformations
simpleMat=ColMat(gamut.sRGBinv)#A Matrix Transform (ColMat) object, created from a color transform matrix for gamut transformations! This one is sRGB --> ACES.
#Indeed, specify many matrices which auto-multiply into a single one! You can also combine them after, with simple multiplication.
#Applying and saving.
img.apply(gFunc).save(path+'/openlut_gammafunc.png')#save saves an image using the appropriate image backend, based on the extension.
img.apply(lut).save(path+'/openlut_lut-lin-16384.png')#apply applies any color transformation object that inherits from Transform - LUT, Func, ColMat, etc., or make your own! It's easy ;) .
img.apply(lut.resized(17)).save(path+'/openlut_lut-lin-17.png')#Why so small? Because spline interpolation automatically turns on. It's identical to the larger LUT!
img.apply(mat).save(path+'/openlut_mat.png')#Applies the gamut transformation.
#As a proof of concept, here's a long list of transformations that should, in sum, do nothing :) :
img.apply(lut).apply(LUT.lutFunc(gamma.sRGB)).apply(mat).apply(~mat).save('testpath/openlut_noop.png')#~mat is the inverse of mat. Easily undo the gamut operation!
#Format Test: All output images are in Linear ACES.
tImg=img.apply(mat)
tImg.save(path+'/output.exr')
tImg.save(path+'/output.dpx')
tImg.save(path+'/output.png')
tImg.save(path+'/output.jpg')
tImg.save(path+'/output.tif')#All sorts of formats work! Bit depth is 16, unless you say something else.
#Compression is impossible right now - wand is being difficult.
#Keep in mind, values are clipped from 0 to 1 when done. Scary transforms can make this an issue!
#Color management is simple: openlut doesn't touch your data, unless you tell it to with a Transform. So, the data that goes in, goes out, unless a Transform was applied.