示例#1
0
def test_grayscale_greater_than_1():
    im = util.fill((4, 4), [174, 56, 3])
    grayscaled_im = css.grayscale(im, 2)
    grayscaleed_im2 = css.grayscale(im, 1)

    assert list(grayscaled_im.getdata()) == list(grayscaleed_im2.getdata())
    assert grayscaled_im.size == im.size
    assert grayscaled_im.mode == im.mode
示例#2
0
def test_grayscale_hsv():
    im = util.fill((4, 4), [174, 56, 3])
    im2 = im.convert('HSV')
    grayscaled_im = css.grayscale(im)
    grayscaled_im2 = css.grayscale(im2)
    grayscaled_im2_rgb = grayscaled_im2.convert('RGB')

    assert list(grayscaled_im.getdata()) == list(grayscaled_im2_rgb.getdata())
    assert grayscaled_im2.size == im2.size
    assert grayscaled_im2.mode == im2.mode
示例#3
0
def test_grayscale_0():
    im = util.fill((4, 4), [174, 56, 3])
    grayscaled_im = css.grayscale(im, 0)

    assert list(grayscaled_im.getdata()) == list(im.getdata())
    assert grayscaled_im.size == im.size
    assert grayscaled_im.mode == im.mode
示例#4
0
def test_saturate_0():
    im = util.fill((4, 4), [174, 56, 3])
    saturated_im = css.saturate(im, 0)
    grayscaled_im = css.grayscale(im)

    assert list(saturated_im.getdata()) == list(grayscaled_im.getdata())
    assert saturated_im.size == im.size
    assert saturated_im.mode == im.mode
示例#5
0
文件: inkwell.py 项目: i10/TangiFlow
def inkwell(im):
    """Applies Inkwell filter.

    Arguments:
        im: An input image.

    Returns:
        The output image.
    """

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

    cr = css.sepia(cb, .3)
    cr = css.contrast(cr, 1.1)
    cr = css.brightness(cr, 1.1)
    cr = css.grayscale(cr)

    return cr
示例#6
0
文件: moon.py 项目: akiomik/pilgram
def moon(im):
    """Applies Moon filter.

    Arguments:
        im: An input image.

    Returns:
        The output image.
    """

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

    cs1 = util.fill(cb.size, [160, 160, 160])
    cs = css.blending.soft_light(cb, cs1)

    cs2 = util.fill(cb.size, [56, 56, 56])
    cr = css.blending.lighten(cs, cs2)

    cr = css.grayscale(cr)
    cr = css.contrast(cr, 1.1)
    cr = css.brightness(cr, 1.1)

    return cr
示例#7
0
def willow(im):
    """Applies Willow filter.

    Arguments:
        im: An input image.

    Returns:
        The output image.
    """

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

    cs1 = util.radial_gradient(cb.size, [(212, 169, 175), (0, 0, 0)],
                               [.55, 1.5])
    cm1 = css.blending.overlay(cb, cs1)

    cs2 = util.fill(cb.size, [216, 205, 203])
    cr = css.blending.color(cm1, cs2)

    cr = css.grayscale(cr, .5)
    cr = css.contrast(cr, .95)
    cr = css.brightness(cr, .9)

    return cr
示例#8
0
def test_grayscale_less_than_0():
    with pytest.raises(AssertionError):
        im = util.fill((4, 4), [174, 56, 3])
        css.grayscale(im, -1)
示例#9
0
def test_grayscale():
    im = util.fill((4, 4), [174, 56, 3])
    grayscaled_im = css.grayscale(im)

    assert grayscaled_im.size == im.size
    assert grayscaled_im.mode == im.mode