#!/usr/bin/env python3 """Regenerate Home's bottle caps — the twelve enamels, the bare cap, the plaster ground in both appearances — and write them into `Media.xcassets`. python3 scripts/gen-caps/make_caps.py --ref [--only red,navy] [--out-dir ] The reference is the owner's picture the design came from (2026-09-13); it is not committed — it lives in his chat. Any picture of the caps you want is a valid reference; the point is that every cap is cut from ONE master so the board shares a geometry, a lens and a light. Three steps: 1. `master.png` — a blank WHITE cap in the reference's style (gpt-image-2, transparent background). Generated once and kept beside the output; pass `--master` to reuse one you already like. 2. Each enamel is an EDIT of the master with the reference as a style image: only the colour changes; geometry, angle, wear and shadow stay. 3. The plaster: the reference's background with no objects on it, and a dark twin of it for Graphite. Then `export_caps.py` trims each cap on its solid alpha and writes the 600 px imagesets. Needs `OPENAI_API_KEY` (or `~/.config/cotton/openai.env`), stdlib only; `export_caps.py` needs Pillow. """ import argparse, pathlib, subprocess, sys HERE = pathlib.Path(__file__).resolve().parent GEN = HERE / "gen_image.py" MASTER_PROMPT = ( "A single vintage metal bottle cap seen exactly from above, perfectly centered and filling " "about 90% of the frame. Match the reference image caps precisely: crimped, fluted steel skirt " "with worn silver edges, slightly domed enamel face with fine scratches, tiny chips and subtle " "wear, soft diffuse studio light from the upper left, a faint contact shadow. The face is plain " "WHITE enamel with NO text, NO logo, NO line, NO symbol — completely blank. Photorealistic " "product photograph, isolated on a fully transparent background." ) RECOLOUR_PROMPT = ( "Two reference images: the FIRST is the cap to edit (keep its exact geometry, camera angle, " "size, lighting and shadow); the SECOND shows the style to match. Repaint the first cap in {colour}: " "the enamel paint covers the ENTIRE cap — the domed face AND the crimped fluted skirt — exactly " "like the coloured caps in the second image. Bare silver steel shows only at a few small chips and " "the worn outermost tips of the flutes. Fine scratches and subtle wear. The face stays completely " "blank: no text, no logo, no line. Photorealistic, fully transparent background." ) EMPTY_PROMPT = ( "Two reference images: the FIRST is the cap to edit (keep its exact geometry, camera angle, size, " "lighting and shadow); the SECOND shows the style to match. Turn the first cap into the EMPTY " "placeholder caps from the bottom rows of the second image: the whole cap — face and crimped skirt — " "is a pale, matte, unpainted off-white / very light warm grey, slightly lighter than the background " "paper, with a subtle brushed texture and very little wear. In the exact centre of the face a thin, " "small, mid-grey plus sign (+), like the ones in the second image — nothing else on the face. " "Photorealistic, fully transparent background." ) PLASTER_PROMPT = ( "Only the background surface from the reference image, with no objects on it at all: a warm " "off-white plaster / matte paper wall, very fine grain, extremely subtle soft vignette, even diffuse " "light, slight warm-grey tone, no texture hotspots, no cracks, no text, no shapes. Photographic, " "seamless, uniform enough to sit behind UI text." ) PLASTER_DARK_PROMPT = ( "The same plaster / matte paper wall texture as the reference image — identical grain, identical " "soft even lighting, no objects, no text, no cracks — but in a deep charcoal graphite tone (a dark, " "slightly warm near-black grey, like dark slate plaster), uniform enough to sit behind pale UI text. " "Photographic, seamless." ) # The twelve enamels, in `CapColour`'s order, and how each is asked for. ENAMELS = { "cream": "a warm vintage cream / ivory (skirt worn silver like the cream cap in the reference)", "red": "a deep vintage cola red", "navy": "a deep navy blue", "yellow": "a rich mustard yellow", "green": "a deep bottle green", "silver": "polished bright silver chrome — bare shiny steel everywhere, no enamel", "orange": "a bright vintage orange", "burgundy": "a deep burgundy wine maroon", "sky": "a soft sky blue", "pink": "a warm salmon pink", "black": "a matte charcoal black", "teal": "a deep teal petrol blue-green", } def gen(out, prompt, refs=(), size="1024x1024", transparent=True): cmd = [sys.executable, str(GEN), "--model", "gpt-image-2", "--quality", "high", "--size", size, "--prompt", prompt, "--out", str(out)] if transparent: cmd.append("--transparent") for r in refs: cmd += ["--ref", str(r)] subprocess.run(cmd, check=True) def main(): ap = argparse.ArgumentParser() ap.add_argument("--ref", required=True, help="the style reference picture") ap.add_argument("--master", help="a blank white master cap to reuse") ap.add_argument("--only", help="comma-separated enamels (and/or 'empty', 'plaster') to regenerate") ap.add_argument("--out-dir", default=str(HERE / "out")) a = ap.parse_args() out = pathlib.Path(a.out_dir) out.mkdir(parents=True, exist_ok=True) only = set(a.only.split(",")) if a.only else None master = pathlib.Path(a.master) if a.master else out / "master.png" if not master.exists(): gen(master, MASTER_PROMPT, refs=[a.ref]) for name, colour in ENAMELS.items(): if only and name not in only: continue gen(out / f"cap-{name}.png", RECOLOUR_PROMPT.format(colour=colour), refs=[master, a.ref]) if not only or "empty" in only: gen(out / "cap-empty.png", EMPTY_PROMPT, refs=[master, a.ref]) if not only or "plaster" in only: gen(out / "plaster.png", PLASTER_PROMPT, refs=[a.ref], size="1024x1536", transparent=False) gen(out / "plaster-dark.png", PLASTER_DARK_PROMPT, refs=[out / "plaster.png"], size="1024x1536", transparent=False) print("now: python3 scripts/gen-caps/export_caps.py", out) if __name__ == "__main__": main()