codex-image
Generate or edit raster images (photos, illustrations, mockups, hero images, product shots, bitmap icons, transparent cutouts) with OpenAI GPT Image 2 by triggering the local Codex CLI, billed to the
SKILL.mdskills/codex-image/SKILL.md
GitHubcodex-image
Runs Codex CLI non-interactively. Codex calls its built-in image_gen tool (GPT Image 2) and the
script copies the result to the path you choose. Each call takes roughly 30–90 seconds.
The script is gen.sh in this skill's base directory (shown when the skill loads), referred to below as <skill-dir>.
Command
<skill-dir>/gen.sh -o <out.png> [options] "<prompt>"
| Option | Meaning |
|---|---|
-o PATH |
Output file (required). Put project assets inside the project; otherwise use a temp/scratch folder. |
-n N |
1–4 variants → out-1.png, out-2.png, … |
-r FILE |
Reference image for style/composition (repeatable) |
-e FILE |
Image to edit — only what the prompt asks changes |
-t |
Transparent background |
-a square|portrait|landscape |
Aspect ratio |
Prints the saved absolute path(s). Never overwrites: an existing name gets a time suffix.
Give the Bash call a timeout of at least 300000 ms (600000 for -n 3 or -n 4). For several different
images, run separate commands in parallel instead of describing them all in one prompt — parallel runs are safe.
Workflow
- Turn the request into a clear prompt: subject, style/medium, composition, lighting, palette, exact text in quotes, and what to avoid. Keep the user's specifics; add detail only when the ask is vague.
- Run
gen.sh. - Look at the output image and check it matches (subject, spelling of any text, framing). If it's off,
rerun with one targeted prompt change, or use
-eon the result for a small fix. - Report the saved path(s) and the final prompt. If the image is for a project, reference it from the code.
Troubleshooting
codex CLI not found→ the user needsnpm i -g @openai/codex.Codex is not logged in→ the user runscodex loginand signs in with ChatGPT.No image was generated→ the ChatGPT plan's image limit may be used up, or the prompt was refused. Say so; don't retry in a loop.-toutput can have semi-transparent blotches. Check it; if dirty, regenerate on a plain white background without-tand remove the background separately.