from PIL import Image, ImageDraw

SRC = '/root/.hermes/webui/attachments/9710c799d486/'
man = Image.open(SRC + '707f2402-9eb3-4aa0-a58b-fbb46d61815f.jpg').crop((0, 250, 946, 1180))
woman = Image.open(SRC + 'e461f313-7e7d-4183-93b2-f3d0e9756d73.jpg').crop((0, 250, 946, 1180))

man_cx = 730
woman_cx = 512
HW = 280

def debug_crop(img, cx, y0, y1, label, color=(255, 0, 0)):
    d = ImageDraw.Draw(img)
    x0, x1 = cx - HW, cx + HW
    d.rectangle([x0, y0, x1, y1], outline=color, width=4)
    d.line([cx, y0, cx, y1], fill=(0, 255, 0), width=3)
    img.save(f'/root/workspace/debug_{label}.jpg', quality=95)
    print(f'{label}: center={cx}, crop=[{x0},{y0},{x1},{y1}]')

debug_crop(man.copy(), man_cx, 220, 930, 'man')
debug_crop(woman.copy(), woman_cx, 80, 740, 'woman')
