1 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
 
   2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
 
  10         c / 12.92 if c < .03928 else ((c + .055) / 1.055) ** 2.4
 
  13     return .2126 * rgb[0] + .7152 * rgb[1] + .0722 * rgb[2]
 
  23 def algo_contrast_or_hue(img, colors):
 
  24     rgb = img.convert('RGB').resize((1, 1)).getpixel((0, 0))
 
  32     hue = img.convert('HSV').resize((1, 1)).getpixel((0, 0))[0]
 
  35         key=lambda c: cdist(hue, c['hsv'][0]) ** 2 + (lumi - c['luminance']) ** 2
 
  39 def is_very_bright(img):
 
  40     rgb = img.convert('RGB').getpixel((0, 0))