Philipp Hörist pushed to branch master at gajim / gajim


Commits:
2abd98c1 by Marc Henning at 2026-09-01T16:51:16+00:00
imprv: Avatar: Use the sRGB relative luminance

HLS lightness is defined as (max+min)/2, which can classify bright colors 
wrongly if they are saturated.

- - - - -


1 changed file:

- gajim/gtk/avatar.py


Changes:

=====================================
gajim/gtk/avatar.py
=====================================
@@ -4,7 +4,6 @@
 
 from __future__ import annotations
 
-import colorsys
 import functools
 import hashlib
 import logging
@@ -111,7 +110,8 @@ def generate_avatar(
 
     text_color = (0.95, 0.95, 0.95)
     if check_contrast:
-        _hue, luminance, _saturation = colorsys.rgb_to_hls(*color)
+        # The constants are the CIE values of sRGB primaries for luminance Y
+        luminance = 0.2126 * color_r + 0.7152 * color_g + 0.0722 * color_b
         if luminance > 0.6:
             # Use dark text color if background luminance threshold is 
surpassed
             text_color = (0.2, 0.2, 0.2)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/2abd98c12a62e412d51e89cabbea218ee8fc3a8f

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/2abd98c12a62e412d51e89cabbea218ee8fc3a8f
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to