summaryrefslogtreecommitdiff
path: root/scheme/resizeimg.py
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-29 18:17:13 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-29 18:17:13 +1100
commit5118c8da96312627b86c55738c02c6c8ac6809d0 (patch)
treeea620f10aa317927879ecbdd1eef9246186f047d /scheme/resizeimg.py
parentinstall: hypr install uwsm envs (diff)
downloadcaelestia-cli-5118c8da96312627b86c55738c02c6c8ac6809d0.tar.gz
caelestia-cli-5118c8da96312627b86c55738c02c6c8ac6809d0.tar.bz2
caelestia-cli-5118c8da96312627b86c55738c02c6c8ac6809d0.zip
scheme: dynamic light theme
Autodetect based on wallpaper Also resize wallpaper so faster And async magick blur so wallpaper doesnt block
Diffstat (limited to 'scheme/resizeimg.py')
-rwxr-xr-xscheme/resizeimg.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/scheme/resizeimg.py b/scheme/resizeimg.py
new file mode 100755
index 0000000..e18ffb8
--- /dev/null
+++ b/scheme/resizeimg.py
@@ -0,0 +1,29 @@
+#!/bin/python
+
+import sys
+import math
+from PIL import Image
+
+
+def calc_size(w, h, b = 128):
+ ia = w * h
+ ba = b * b
+ s = math.sqrt(ba / ia) if ia > ba else 1
+ return max(1, round(w * s)), max(1, round(h * s))
+
+
+def resize(img):
+ w, h = calc_size(img.width, img.height)
+ if w < img.width or h < img.height:
+ return img.resize((w, h), Image.Resampling.BICUBIC), True
+ return img, False
+
+
+if __name__ == "__main__":
+ with Image.open(sys.argv[1]) as img:
+ img, resized = resize(img)
+ if resized:
+ img.save("/tmp/caelestia-resize.png")
+ print("/tmp/caelestia-resize.png")
+ else:
+ print(sys.argv[1])