def test_radial_gradient_255_to_0(): # this case is the same as radial_gradient_mask w, h = (5, 5) gradient = util.radial_gradient((w, h), [[255, 255, 255], [0, 0, 0]]) expected = util.radial_gradient_mask((w, h)) assert list(gradient.getdata(0)) == list(expected.getdata()) assert list(gradient.getdata(1)) == list(expected.getdata()) assert list(gradient.getdata(2)) == list(expected.getdata()) assert gradient.size == (w, h) assert gradient.mode == 'RGB'
def toaster(im): """Applies Toaster filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs = util.radial_gradient(cb.size, [(128, 78, 15), (59, 0, 59)]) cr = css.blending.screen(cb, cs) cr = css.contrast(cr, 1.5) cr = css.brightness(cr, .9) return cr
def earlybird(im): """Applies Earlybird filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs = util.radial_gradient(cb.size, [(208, 186, 142), (54, 3, 9), (29, 2, 16)], [.2, .85, 1]) cr = css.blending.overlay(cb, cs) cr = css.contrast(cr, .9) cr = css.sepia(cr, .2) return cr
def hudson(im): """Applies Hudson filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs = util.radial_gradient(cb.size, [(166, 177, 255), (52, 33, 52)], [.5, 1]) cs = css.blending.multiply(cb, cs) cr = Image.blend(cb, cs, .5) # opacity cr = css.brightness(cr, 1.2) cr = css.contrast(cr, .9) cr = css.saturate(cr, 1.1) return cr
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