wallpaper: better variant detection

This commit is contained in:
2 * r + 2 * t
2025-06-25 23:44:50 +10:00
parent 49db0a8258
commit 35ea4a2dbc
2 changed files with 49 additions and 5 deletions
+7 -5
View File
@@ -80,14 +80,16 @@ def get_smart_opts(wall: Path, cache: Path) -> str:
except (IOError, json.JSONDecodeError):
pass
from caelestia.utils.colourfulness import get_variant
opts = {}
with Image.open(get_thumb(wall, cache)) as img:
opts["variant"] = get_variant(img)
img.thumbnail((1, 1), Image.LANCZOS)
hct = Hct.from_int(argb_from_rgb(*img.getpixel((0, 0))))
opts = {
"mode": "light" if hct.tone > 60 else "dark",
"variant": "neutral" if hct.chroma < 20 else "tonalspot",
}
opts["mode"] = "light" if hct.tone > 60 else "dark"
opts_cache.parent.mkdir(parents=True, exist_ok=True)
with opts_cache.open("w") as f: