コード例 #1
0
def test_merge_mask_layer_from_with_mask_not_available_in_files_in_both_collections_and_foreground_color_black():
    with TemporaryDirectory('_src') as srcdir, TemporaryDirectory('_dst') as dstdir:
        src_1 = GimpFile(os.path.join(srcdir, 'file1.xcf')) \
            .create_empty(2, 1, GimpFileType.GRAY)

        dst_1 = GimpFile(os.path.join(dstdir, 'file1.xcf')) \
            .create_empty(2, 1, GimpFileType.GRAY)

        src_collection = GimpFileCollection([src_1.get_file()])
        dst_collection = GimpFileCollection([dst_1.get_file()])

        dst_collection.merge_mask_layer_from(src_collection, 'Mask', MaskForegroundColor.BLACK, timeout_in_seconds=10)

        assert np.all(dst_1.layer_to_numpy('Mask') == [[255], [255]])
        assert ['Mask'] == dst_1.layer_names()
コード例 #2
0
def test_merge_mask_layer_from_with_color():
    with TemporaryDirectory('_src') as srcdir, TemporaryDirectory('_dst') as dstdir:
        src_1 = GimpFile(os.path.join(srcdir, 'file1.xcf'))\
            .create('Mask', np.array([[[255, 255, 255], [0, 0, 0]]], dtype=np.uint8))

        dst_1 = GimpFile(os.path.join(dstdir, 'file1.xcf')) \
            .create('Mask', np.array([[[0, 0, 0], [255, 255, 255]]], dtype=np.uint8))
        dst_2 = GimpFile(os.path.join(dstdir, 'file2.xcf')) \
            .create('Mask', np.array([[[0, 0, 0], [255, 255, 255]]], dtype=np.uint8))

        src_collection = GimpFileCollection([src_1.get_file()])
        dst_collection = GimpFileCollection([dst_1.get_file(), dst_2.get_file()])

        dst_collection.merge_mask_layer_from(src_collection, 'Mask', MaskForegroundColor.WHITE, timeout_in_seconds=10)

        assert np.all(dst_1.layer_to_numpy('Mask') == [[255, 255, 255], [255, 255, 255]])
        assert ['Mask'] == dst_1.layer_names()
        assert 'Mask' in dst_2.layer_names()
        assert np.all(dst_2.layer_to_numpy('Mask') == [[0, 0, 0], [255, 255, 255]])
        assert ['Mask'] == dst_2.layer_names()