示例#1
0
def test_linear_gradient_mask_vertical():
    w, h = (4, 4)
    mask = util.linear_gradient_mask((w, h), is_horizontal=False)

    assert list(mask.getdata()) == [223] * w + [159] * w + [95] * w + [31] * w
    assert mask.size == (w, h)
    assert mask.mode == 'L'
示例#2
0
def test_linear_gradient_mask_horizontal():
    w, h = (4, 4)
    mask = util.linear_gradient_mask((w, h))

    assert list(mask.getdata()) == [223, 159, 95, 31] * h
    assert mask.size == (w, h)
    assert mask.mode == 'L'
示例#3
0
def test_linear_gradient_mask_prepared_horizontal():
    w, h = (4, 4)
    mask = util.linear_gradient_mask((w, h))

    assert list(mask.getdata()) == [222, 161, 94, 33] * h
    assert mask.size == (w, h)
    assert mask.mode == 'L'
示例#4
0
def test_linear_gradient_mask_start_end():
    w, h = (4, 4)
    start = 100 / 255
    end = 200 / 255
    mask = util.linear_gradient_mask((w, h), start=start, end=end)

    assert list(mask.getdata()) == [100, 133, 166, 200] * h
    assert mask.size == (w, h)
    assert mask.mode == 'L'
示例#5
0
def test_linear_gradient_mask_start_end_vertical():
    w, h = (4, 4)
    start = 100 / 255
    end = 200 / 255
    mask = util.linear_gradient_mask((w, h),
                                     start=start,
                                     end=end,
                                     is_horizontal=False)

    expected = [100] * w + [133] * w + [166] * w + [200] * w

    assert list(mask.getdata()) == expected
    assert mask.size == (w, h)
    assert mask.mode == 'L'
示例#6
0
文件: aden.py 项目: i10/TangiFlow
def aden(im):
    """Applies Aden filter.

    Arguments:
        im: An input image.

    Returns:
        The output image.
    """

    cb = util.or_convert(im, 'RGB')

    cs = util.fill(cb.size, [66, 10, 14])
    cs = ImageChops.darker(cb, cs)

    alpha_mask = util.linear_gradient_mask(cb.size, start=.8)
    cr = Image.composite(cs, cb, alpha_mask)

    cr = css.hue_rotate(cr, -20)
    cr = css.contrast(cr, .9)
    cr = css.saturate(cr, .85)
    cr = css.brightness(cr, 1.2)

    return cr