improve auto color scheme performance

This commit is contained in:
end-4
2025-11-22 11:34:24 +01:00
parent 68c159f210
commit cd7bf9c1c2
@@ -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)