예제 #1
0
fImgs = [[ao, ao_srgb], [roughness, roughness_srgb], [metallic, metallic_srgb],
         [emissive, emissive_srgb]]
imgs = {}

foundSize = False

for i in range(len(fImgs)):
    fImg, is_sRGB = fImgs[i]
    if fImg.exists():
        img = PNMImage()
        img.read(fImg)
        img.makeRgb()
        if is_sRGB:
            # Convert to linear
            print("Converting", getChannelName(i), "to linear")
            img.applyExponent(2.2)
        if not foundSize:
            size = [img.getReadXSize(), img.getReadYSize()]
            foundSize = True
        imgs[i] = img
    else:
        # assume it is a constant value
        val = float(fImg.getFullpath())
        if is_sRGB:
            print("Converting", getChannelName(i), "to linear")
            # Convert to linear
            val = math.pow(val, 2.2)
        imgs[i] = val

print("Size:", size)
from panda3d.core import PNMImage, Filename

inputFile = raw_input("Input linear image: ")
inputFilename = Filename.fromOsSpecific(inputFile)
outputFile = raw_input("Output sRGB image: ")
outputFilename = Filename.fromOsSpecific(outputFile)

img = PNMImage()
img.read(inputFilename)
img.applyExponent(1.0 / 2.2)
img.write(outputFilename)

print("Done")