#!/usr/bin/env python3 """Regenerate the todo cards — six dyed papers and the two rubber stamps — and leave them in an out-dir for `export_cards.py` to write into `Media.xcassets`. python3 scripts/gen-cards/make_cards.py --ref [--master ] [--only blue,stamp-done] [--out-dir ] The reference is the owner's picture of typed paper index cards (2026-09-13); it is not committed — it lives in his chat. The shape is the caps' shape (`scripts/gen-caps/make_caps.py`): every paper is cut from ONE master so the set shares one geometry, one grain and one light. Three steps: 1. `card-a.png` — a blank CREAM card 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. The master IS the cream paper. 2. Each dye is an EDIT of the master with the reference as a second image: only the paper's colour changes; edges, grain, lighting and shadow stay. 3. The stamps: `stamp-a.png` is the red DONE impression generated from the reference; `stamp-dropped.png` is an EDIT of it — same border, same letters, the word and the ink changed. Nothing is written on a card here. The label, the day, the meta line and the check are set live in SwiftUI and multiplied onto the paper, the caps' trick. Then `export_cards.py` cuts every card with the master's box and writes the imagesets. Needs `OPENAI_API_KEY` (or `~/.config/cotton/openai.env`) through `scripts/gen-caps/gen_image.py`, stdlib only; `export_cards.py` needs Pillow. """ import argparse, pathlib, subprocess, sys HERE = pathlib.Path(__file__).resolve().parent # The one image tool, shared with the caps — reached by path, never copied. GEN = HERE.parent / "gen-caps" / "gen_image.py" CARD_SIZE = "1536x1024" STAMP_SIZE = "1024x1024" MASTER_PROMPT = ( "Using the reference image only for its style: produce ONE blank paper index card exactly like " "the cards in the reference: a horizontal rectangle of plain warm cream card stock with very " "slightly uneven, softly worn edges and gently rounded corners, a faint paper grain, a subtle " "darker edge on the lower side, a soft shadow beneath as if lying on a wall. The card is " "completely BLANK: no text, no checkbox, no stamp, no lines, no marks of any kind. " "Photorealistic, the card centred and filling about 92 percent of the frame width, isolated on " "a fully transparent background." ) DYE_PROMPT = ( "Two reference images: the FIRST is the blank paper card to edit (keep its exact geometry, worn " "edges, grain, lighting and shadow); the SECOND shows the style to match. Recolour the first card " "so its paper is {colour}. The colour is the paper itself, evenly dyed card stock, not a coating. " "The card stays completely BLANK: no text, no checkbox, no stamp, no marks. Photorealistic, fully " "transparent background." ) DONE_PROMPT = ( "Using the reference image only for its style: produce ONE red rubber stamp impression reading " "exactly DONE in bold condensed capital letters inside a rounded rectangular border, exactly like " "the DONE stamp on the blue card in the reference, slightly uneven ink coverage with small gaps as " "a real rubber stamp leaves, slightly rotated by about 12 degrees, red ink only, nothing else in " "the picture, isolated on a fully transparent background, filling about 85 percent of the frame " "width." ) DROPPED_PROMPT = ( "Two reference images: the FIRST is the rubber stamp impression to edit (keep its exact border " "shape, letter style, ink texture, rotation and size); the SECOND shows the style to match. Change " "the word to exactly DROPPED in the same bold condensed capitals, and change the ink from red to a " "muted warm grey. Slightly uneven ink coverage with small gaps as a real rubber stamp leaves. " "Nothing else in the picture, isolated on a fully transparent background." ) # The five dyes, keyed by the paper's name in the catalogue (`card-`). # Cream is the master itself. Which paper a todo gets is its project's cap # colour, decided in the app (`CapColour.assign`) — nothing is stored. DYES = { "blue": "a soft dusty blue-grey, exactly like the blue cards in the reference", "pink": "a soft dusty rose pink, exactly like the pink cards in the reference", "sage": "a soft muted sage green, exactly like the green cards in the reference", "straw": "a soft pale straw yellow, exactly like the yellow card in the reference", "peach": "a soft pale peach, exactly like the peach-toned cards in the reference", } STAMPS = ("stamp-done", "stamp-dropped") def gen(out, prompt, refs=(), size=CARD_SIZE): cmd = [ sys.executable, str(GEN), "--model", "gpt-image-2", "--quality", "high", "--size", size, "--prompt", prompt, "--out", str(out), "--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 cream master card to reuse (card-a.png)") ap.add_argument("--only", help=f"comma-separated: any of {','.join(DYES)},{','.join(STAMPS)}") 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 if only: unknown = only - set(DYES) - set(STAMPS) if unknown: sys.exit(f"--only names nothing this makes: {', '.join(sorted(unknown))}") master = pathlib.Path(a.master) if a.master else out / "card-a.png" if not master.exists(): gen(master, MASTER_PROMPT, refs=[a.ref]) for name, colour in DYES.items(): if only and name not in only: continue gen(out / f"card-{name}.png", DYE_PROMPT.format(colour=colour), refs=[master, a.ref]) done = out / "stamp-a.png" if not only or "stamp-done" in only or (not done.exists() and "stamp-dropped" in only): gen(done, DONE_PROMPT, refs=[a.ref], size=STAMP_SIZE) if not only or "stamp-dropped" in only: gen(out / "stamp-dropped.png", DROPPED_PROMPT, refs=[done, a.ref], size=STAMP_SIZE) print("now: python3 scripts/gen-cards/export_cards.py", out) if __name__ == "__main__": main()