""" 采用设定稿:work/sheets/<动作>.png → assets/sheets/<动作>.webp(无损,约为 PNG 的一半大小) 用法:python3 coach_adopt.py <动作> [动作 ...] """ import sys from pathlib import Path from PIL import Image ROOT = Path(__file__).resolve().parents[1] if __name__ == "__main__": for move in sys.argv[1:]: src = ROOT / "work" / "sheets" / f"{move}.png" im = Image.open(src) if im.mode != "RGBA" or im.getchannel("A").getextrema()[0] > 0: raise SystemExit(f"{src.name} 不是透明背景,不能使用") dst = ROOT / "assets" / "sheets" / f"{move}.webp" im.save(dst, lossless=True, quality=100, method=6) print(f"已采用 {src.relative_to(ROOT)} → {dst.relative_to(ROOT)}({im.width}×{im.height})")