generate: per-prompt SIZES and several names/--all; adopt: --size

Optional and backward compatible: SIZES = {name: (w, h)} in the prompt
module overrides the latent/scheduler size, generate.py accepts several
names or --all (PROMPTS + BACKDROPS), adopt.py --size N for larger sprites.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-14 16:36:58 +02:00
parent 9b35c3a7cc
commit 53e83ad096
2 changed files with 36 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ PictureBoxSizeMode.Zoom, so square keeps every icon the same visual size.
py -3.12 adopt.py stat_health one sprite
py -3.12 adopt.py stat_health life_baby several
py -3.12 adopt.py --all every name in the prompt list
py -3.12 adopt.py --size 512 hero larger square (default 128)
"""
import glob
import importlib
@@ -27,7 +28,8 @@ MARGIN = 0.04 # share of the side left free around the icon
ALPHA_THRESHOLD = 8
def adopt(name):
def adopt(name, size=None):
size = size or SIZE
raws = sorted(glob.glob(os.path.join(config.OUTPUT_DIR, f"{name}_raw_*.png")),
key=os.path.getmtime)
if not raws:
@@ -44,7 +46,7 @@ def adopt(name):
side = int(max(image.size) * (1 + 2 * MARGIN))
square = Image.new("RGBA", (side, side), (0, 0, 0, 0))
square.paste(image, ((side - image.width) // 2, (side - image.height) // 2))
square = square.resize((SIZE, SIZE), Image.LANCZOS)
square = square.resize((size, size), Image.LANCZOS)
os.makedirs(DEST, exist_ok=True)
dest = os.path.join(DEST, f"{name}.png")
@@ -73,6 +75,10 @@ def adopt_backdrop(name, width=1920, height=1080):
if __name__ == "__main__":
args = sys.argv[1:]
size = None
if len(args) >= 2 and args[0] == "--size":
size = int(args[1])
args = args[2:]
if not args:
print(__doc__)
sys.exit(1)
@@ -81,5 +87,5 @@ if __name__ == "__main__":
if args == ["--all"]:
prompts = importlib.import_module(getattr(config, "PROMPTS_MODULE", "prompts_life"))
args = [p[0] for p in prompts.PROMPTS]
ok = sum(adopt(n) for n in args)
ok = sum(adopt(n, size) for n in args)
print(f"{ok}/{len(args)} adopted")