def testChannelsAreSeparate(self): i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/circles.exr")) o = GafferImage.DisplayTransform() o["in"].setInput(i["out"]) o["inputColorSpace"].setValue("linear") self.assertNotEqual(o["out"].channelDataHash("R", imath.V2i(0)), o["out"].channelDataHash("G", imath.V2i(0))) self.assertNotEqual(o["out"].channelData("R", imath.V2i(0)), o["out"].channelData("G", imath.V2i(0)))
def testImageHashPassThrough(self): i = GafferImage.ImageReader() i["fileName"].setValue(self.imageFile) o = GafferImage.DisplayTransform() o["in"].setInput(i["out"]) self.assertEqual(GafferImage.ImageAlgo.imageHash(i["out"]), GafferImage.ImageAlgo.imageHash(o["out"])) o["inputColorSpace"].setValue("linear") o["display"].setValue("default") o["view"].setValue("rec709") self.assertNotEqual(GafferImage.ImageAlgo.imageHash(i["out"]), GafferImage.ImageAlgo.imageHash(o["out"]))
def testHashPassThrough(self): n = GafferImage.ImageReader() n["fileName"].setValue(self.imageFile) o = GafferImage.DisplayTransform() o["in"].setInput(n["out"]) self.assertImageHashesEqual(n["out"], o["out"]) self.assertImagesEqual(n["out"], o["out"]) o["inputColorSpace"].setValue("linear") o["display"].setValue("default") o["view"].setValue("rec709") self.assertNotEqual(GafferImage.ImageAlgo.image(n["out"]), GafferImage.ImageAlgo.image(o["out"])) o["enabled"].setValue(False) self.assertImageHashesEqual(n["out"], o["out"]) self.assertImagesEqual(n["out"], o["out"]) self.assertEqual(n["out"]['format'].hash(), o["out"]['format'].hash()) self.assertEqual(n["out"]['dataWindow'].hash(), o["out"]['dataWindow'].hash()) self.assertEqual(n["out"]["metadata"].getValue(), o["out"]["metadata"].getValue()) self.assertEqual(n["out"]['channelNames'].hash(), o["out"]['channelNames'].hash()) o["enabled"].setValue(True) o["inputColorSpace"].setValue("") self.assertImageHashesEqual(n["out"], o["out"]) self.assertImagesEqual(n["out"], o["out"]) self.assertEqual(n["out"]['format'].hash(), o["out"]['format'].hash()) self.assertEqual(n["out"]['dataWindow'].hash(), o["out"]['dataWindow'].hash()) self.assertEqual(n["out"]["metadata"].getValue(), o["out"]["metadata"].getValue()) self.assertEqual(n["out"]['channelNames'].hash(), o["out"]['channelNames'].hash())
def testPassThrough( self ) : i = GafferImage.ImageReader() i["fileName"].setValue( self.imageFile ) o = GafferImage.DisplayTransform() o["in"].setInput( i["out"] ) o["inputColorSpace"].setValue( "linear" ) o["display"].setValue( "default" ) o["view"].setValue( "rec709" ) self.assertEqual( i["out"]["format"].hash(), o["out"]["format"].hash() ) self.assertEqual( i["out"]["dataWindow"].hash(), o["out"]["dataWindow"].hash() ) self.assertEqual( i["out"]["metadata"].getValue(), o["out"]["metadata"].getValue() ) self.assertEqual( i["out"]["channelNames"].hash(), o["out"]["channelNames"].hash() ) self.assertEqual( i["out"]["format"].getValue(), o["out"]["format"].getValue() ) self.assertEqual( i["out"]["dataWindow"].getValue(), o["out"]["dataWindow"].getValue() ) self.assertEqual( i["out"]["metadata"].getValue(), o["out"]["metadata"].getValue() ) self.assertEqual( i["out"]["channelNames"].getValue(), o["out"]["channelNames"].getValue() )
def testContext(self): scriptFileName = self.temporaryDirectory() + "/script.gfr" contextImageFile = self.temporaryDirectory() + "/context.#.exr" contextOverrideImageFile = self.temporaryDirectory( ) + "/context_override.#.exr" s = Gaffer.ScriptNode() s["reader"] = GafferImage.ImageReader() s["reader"]["fileName"].setValue(self.imageFile) s["dt"] = GafferImage.DisplayTransform() s["dt"]["in"].setInput(s["reader"]["out"]) s["dt"]["inputColorSpace"].setValue("linear") s["dt"]["display"].setValue("default") s["dt"]["view"].setValue("context") s["writer"] = GafferImage.ImageWriter() s["writer"]["fileName"].setValue(contextImageFile) s["writer"]["in"].setInput(s["dt"]["out"]) s["writer"]["channels"].setValue("R G B A") s["fileName"].setValue(scriptFileName) s.save() env = os.environ.copy() env["OCIO"] = os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/openColorIO/context.ocio") env["LUT"] = "srgb.spi1d" env["CDL"] = "cineon.spi1d" subprocess.check_call( " ".join(["gaffer", "execute", scriptFileName, "-frames", "1"]), shell=True, stderr=subprocess.PIPE, env=env, ) i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/checker_ocio_context.exr" )) o = GafferImage.ImageReader() o["fileName"].setValue(contextImageFile) expected = i["out"] context = o["out"] # check against expected output self.assertImagesEqual(expected, context, ignoreMetadata=True) # override context s["writer"]["fileName"].setValue(contextOverrideImageFile) s["dt"]["context"].addOptionalMember("LUT", "cineon.spi1d", "LUT", enabled=True) s["dt"]["context"].addOptionalMember("CDL", "rec709.spi1d", "CDL", enabled=True) s.save() subprocess.check_call(" ".join( ["gaffer", "execute", scriptFileName, "-frames", "1"]), shell=True, stderr=subprocess.PIPE, env=env) i = GafferImage.ImageReader() i["fileName"].setValue( os.path.expandvars( "$GAFFER_ROOT/python/GafferImageTest/images/checker_ocio_context_override.exr" )) o = GafferImage.ImageReader() o["fileName"].setValue(contextOverrideImageFile) expected = i["out"] context = o["out"] # check override produce expected output self.assertImagesEqual(expected, context, ignoreMetadata=True)