def testDefaults(self): op = IECoreImage.ImageCropOp() self.assertTrue(op['cropBox'].getValue().value.isEmpty()) self.assertEqual(op['resetOrigin'].getValue().value, True) self.assertEqual(op['matchDataWindow'].getValue().value, True)
def testEmptyCropBox( self ) : image = IECore.Reader.create( "test/IECoreImage/data/exr/colorBarsWithDataWindow.exr" ).read() op = IECoreImage.ImageCropOp() executeOp = IECore.curry( op, object = image ) self.assertRaises( RuntimeError, executeOp )
def testEmptyCropBox(self): image = IECore.Reader.create( os.path.join("test", "IECoreImage", "data", "exr", "colorBarsWithDataWindow.exr")).read() op = IECoreImage.ImageCropOp() executeOp = IECore.curry(op, object=image) self.assertRaises(RuntimeError, executeOp)
def __testCrop(self, inputfile, tests): r = IECore.Reader.create(inputfile) img = r.read() self.assertEqual(type(img), IECoreImage.ImagePrimitive) cropOp = IECoreImage.ImageCropOp() errors = [] testIdx = 0 for testCase in tests: testIdx = testIdx + 1 cropOp['copyInput'] = True cropOp['cropBox'] = testCase['cropBox'] cropOp['matchDataWindow'] = testCase.get('matchDataWindow', True) resetOrigin = testCase.get('resetOrigin', True) cropOp['resetOrigin'] = resetOrigin cropOp['extendDataWindow'] = False cropOp['input'] = img croppedImg = cropOp() if not croppedImg.channelsValid(): raise Exception( "Invalid cropped image in test case: " + str(testCase) + ". Image info (displayWindow, dataWindow,bufferSize): " + str(croppedImg.displayWindow) + ", " + str(croppedImg.dataWindow) + ", " + str(len(croppedImg["R"]))) #Uncomment to generate missing expected result files #if not os.path.exists( testCase['checkFile'] ) : # IECore.Writer.create( croppedImg, testCase['checkFile'] ).write() expectedImg = IECore.Reader.create(testCase['checkFile']).read() expectedImg.blindData().clear() croppedImg.blindData().clear() if croppedImg == expectedImg: continue errors.append("Crop test case failed:" + str(testCase) + ". Cropped image: " + str(croppedImg.displayWindow) + " " + str(croppedImg.dataWindow) + " Loaded image: " + str(expectedImg.displayWindow) + " " + str(expectedImg.dataWindow)) if len(errors): raise Exception("\n".join(errors))