def test_hue_rotate_less_than_0(): im = util.fill((4, 4), [174, 56, 3]) hue_rotated_im = css.hue_rotate(im, -42) hue_rotated_im2 = css.hue_rotate(im) assert list(hue_rotated_im.getdata()) != list(hue_rotated_im2.getdata()) assert hue_rotated_im.size == im.size assert hue_rotated_im.mode == im.mode
def test_hue_rotate_360(): im = util.fill((4, 4), [174, 56, 3]) hue_rotated_im = css.hue_rotate(im) hue_rotated_im2 = css.hue_rotate(im, 360) assert list(hue_rotated_im.getdata()) == list(hue_rotated_im2.getdata()) assert hue_rotated_im.size == im.size assert hue_rotated_im.mode == im.mode
def test_hue_rotate_hsv(): im = util.fill((4, 4), [174, 56, 3]) im2 = im.convert('HSV') hue_rotated_im = css.hue_rotate(im) hue_rotated_im2 = css.hue_rotate(im2) hue_rotated_im2_rgb = hue_rotated_im2.convert('RGB') hue_rotated_im_data = list(hue_rotated_im.getdata()) hue_rotated_im2_rgb_data = list(hue_rotated_im2_rgb.getdata()) assert hue_rotated_im_data == hue_rotated_im2_rgb_data assert hue_rotated_im2.size == im2.size assert hue_rotated_im2.mode == im2.mode
def gingham(im): """Applies Gingham filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs = util.fill(cb.size, [230, 230, 250]) cr = css.blending.soft_light(cb, cs) cr = css.brightness(cr, 1.05) cr = css.hue_rotate(cr, -10) return cr
def walden(im): """Applies Walden filter. Arguments: im: An input image. Returns: The output image. """ cb = util.or_convert(im, 'RGB') cs = util.fill(cb.size, [0, 68, 204]) cs = ImageChops.screen(cb, cs) cr = Image.blend(cb, cs, .3) cr = css.brightness(cr, 1.1) cr = css.hue_rotate(cr, -10) cr = css.sepia(cr, .3) cr = css.saturate(cr, 1.6) return cr
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