# 批量裁切AI水印
# D181 · 2026-07-10 · 耳耳蛋签发
from PIL import Image
import os

OUT_DIR = os.path.join(os.path.dirname(__file__), '..', 'projects', 'deep-sea-voyage', 'outputs')
OUT_DIR = os.path.abspath(OUT_DIR)

FILES = [
    'ENV-001-crew-quarters.png',
    'ENV-002-hatch-window.png',
    'PROP-001-tool-bag.png',
    'PROP-002-id-badge.png',
    'PROP-003-pipe-wrench.png',
    'PROP-004-flashlight.png',
]

# Seedream/ImageGen 水印在右下角，裁底部 100px 确保干净
CROP_BOTTOM = 100

for fname in FILES:
    fpath = os.path.join(OUT_DIR, fname)
    if not os.path.exists(fpath):
        print(f'⏭ {fname} 不存在，跳过')
        continue

    img = Image.open(fpath)
    w, h = img.size
    new_h = h - CROP_BOTTOM

    # 裁掉底部水印区域
    cropped = img.crop((0, 0, w, new_h))

    # 备份原图
    bak = fpath.replace('.png', '-watermarked.png')
    img.save(bak)

    # 保存裁切后的图
    cropped.save(fpath)
    print(f'✅ {fname}: {w}x{h} → {w}x{new_h} | 备份: {os.path.basename(bak)}')

print('\n🎬 全部裁切完成！')
