def test_merge_layer_from_file(): with TempFile('.xcf') as dst, TempFile('.xcf') as src: layer_bg = np.array([ [[255, 255, 255], [0, 0, 0], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255]], ], dtype=np.uint8) src_file = GimpFile(src) src_file.create('Background', np.zeros(shape=(2, 3, 3), dtype=np.uint8)) src_file.add_layer_from_numpy( 'Yellow', np.array([ [[240, 255, 0], [240, 255, 0], [240, 255, 0]], [[240, 255, 0], [240, 255, 0], [240, 255, 0]], ], dtype=np.uint8)) dst_file = GimpFile(dst) dst_file.create('Yellow', layer_bg) dst_file.merge_layer_from_file(src_file, 'Yellow') new_layer_contents = dst_file.layer_to_numpy('Yellow') assert np.all([240, 255, 0] == new_layer_contents)
def test_merge_layer_from_file_with_cleared_selection(): src = file.relative_to(__file__, 'test-resources/selection.xcf') with TempFile('.xcf') as dst: src_file = GimpFile(src) dst_file = GimpFile(dst) dst_file.create('Background', np.zeros(shape=(3, 3, 3), dtype=np.uint8)) dst_file.merge_layer_from_file(src_file, 'Background') new_layer_contents = dst_file.layer_to_numpy('Background') assert np.all( np.array([ [[255, 255, 255], [255, 255, 255], [255, 255, 255]], [[255, 0, 0], [255, 0, 0], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255]], ], dtype=np.uint8) == new_layer_contents)