#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Sampling warna dari desain TSC yang sudah tayang -> palet untuk generator feed."""
from PIL import Image
from collections import Counter

WS = "/home/mantapman/.hermes/profiles/atun/workspace"

def top(path, box=None, n=8):
    im = Image.open(f"{WS}/{path}").convert("RGB")
    if box:
        im = im.crop(box)
    im = im.resize((160, 200))
    c = Counter(im.getdata())
    print(f"\n{path} {box or ''}")
    for rgb, cnt in c.most_common(n):
        print(f"  #{rgb[0]:02X}{rgb[1]:02X}{rgb[2]:02X}  {cnt}")

# terang: area teks kiri (latar) + headline navy + aksen
top("openclaw-img/tsc_design_01.jpg", (0, 200, 520, 700))
top("openclaw-img/tsc_design_01.jpg", (60, 320, 520, 470))     # headline serif
top("openclaw-img/tsc_design_01.jpg", (40, 1140, 480, 1250))   # pill CTA
# gelap: latar + aksen kuning
top("openclaw-img/tsc_ig_baru_1.jpg", (0, 0, 200, 300))
top("openclaw-img/tsc_ig_baru_1.jpg", (200, 520, 900, 950))    # script kuning
