diff --git a/dots/.config/quickshell/ii/scripts/colors/scheme_for_image.py b/dots/.config/quickshell/ii/scripts/colors/scheme_for_image.py index 7adc8ce70..1f58da77b 100755 --- a/dots/.config/quickshell/ii/scripts/colors/scheme_for_image.py +++ b/dots/.config/quickshell/ii/scripts/colors/scheme_for_image.py @@ -35,6 +35,16 @@ def pick_scheme(colorfulness): else: return "scheme-tonal-spot" +def load_and_resize_image(img_path, max_dim=128): + img = cv2.imread(img_path) + if img is None: + return None + h, w = img.shape[:2] + if max(h, w) > max_dim: + scale = max_dim / max(h, w) + img = cv2.resize(img, (int(w * scale), int(h * scale)), interpolation=cv2.INTER_AREA) + return img + def main(): colorfulness_mode = False args = sys.argv[1:] @@ -45,7 +55,7 @@ def main(): print("scheme-tonal-spot") sys.exit(1) img_path = args[0] - img = cv2.imread(img_path) + img = load_and_resize_image(img_path) if img is None: print("scheme-tonal-spot") sys.exit(1)