/install codex-imggen
Codex Image Generation
⚠️ 美术必读 — Size 限制:Codex CLI 最大输出 ~1.57MP(1254×1254 级别),所有尺寸都会被卡在这个上限内。4K/FHD/2K 都会降级,不会真的输出那些尺寸。详见下方安全尺寸表。
Size 限制速查
| 用途 | 推荐尺寸 | 实际输出 | 风险 |
|---|---|---|---|
| 方图素材(安全) | 1K / 1:1 / square |
1254×1254 | ✅ 无缩放 |
| 横版大图(安全) | 1536x1024 |
1536×1024 | ✅ 无缩放(唯一精确大尺寸) |
| 竖版素材(安全) | 9:16 |
941×1672 | ✅ 无缩放 |
| 横版4:3(安全) | 4:3 |
1448×1086 | ✅ 无缩放 |
| 16:9 横版 | 2K / FHD / 16:9 |
1672×941 | ⚠️ 实际只有 ~HD 级 |
| 4K / 1080p / 720p | ❌ 勿用 | 全部降级至 1672×941 | ❌ 严重缩水 |
| 小图如 512×512 | ❌ 勿用 | 膨胀至 1254×1254 | ❌ 严重放大 |
结论:游戏 UI 素材推荐用 1K(方图)或 1536x1024(横版),不要用 FHD/4K/720p 等标识。
Quick Reference
| Task | Command |
|---|---|
| Single image | bash ~/.openclaw/skills/codex-imggen/scripts/generate.sh "\x3Cprompt>" [output_dir] |
| Size-controlled | bash ~/.openclaw/skills/codex-imggen/scripts/gen_size.sh \x3Csize_key> "\x3Csubject>" [output_dir] |
| Batch game UI | bash ~/.openclaw/skills/codex-imggen/scripts/batch_generate.sh "\x3Cstyle>" \x3Ccount> [output_dir] |
Size Keys (gen_size.sh)
| Key | Actual Output | Aspect | MP | Accuracy |
|---|---|---|---|---|
1K / 1:1 / square |
1254×1254 | 1:1 | ~1.57MP | ✅ ~1K (diff \x3C3%) |
2K / 16:9 / FHD |
1672×941 | 16:9 | ~1.57MP | ⚠️ ~2K (diff -22% area) |
2048x1080 |
1727×911 | ~17:9 | ~1.57MP | ✅ Best 2K match |
4K / 3840x2160 |
1672×941 | 16:9 | ~1.57MP | ❌ Cannot reach 4K |
9:16 |
941×1672 | 9:16 | ~1.57MP | ✅ Portrait |
4:3 |
1448×1086 | 4:3 | ~1.57MP | ✅ |
1536x1024 |
1536×1024 | 3:2 | ~1.57MP | ✅ Exact |
720p / HD |
1672×941 | 16:9 | ~1.57MP | ⚠️ Same as 2K |
核心约束:Codex CLI 所有输出被强制限制在 ~1.57MP 以内。4K / FHD / 2K / 720p 等大尺寸标识均会被降级处理,只有
1K、1536x1024、9:16、4:3能保持原始比例不缩放。
Generating Images
Single image
bash ~/.openclaw/skills/codex-imggen/scripts/generate.sh \
"A fantasy sword with golden blade on white background (#ffffff), flat vector art style" \
/tmp/my-images
With size control
bash ~/.openclaw/skills/codex-imggen/scripts/gen_size.sh \
"1K" \
"A medieval castle on a hill at sunset" \
/tmp/my-images
Batch game UI assets (proven 2026-05-21)
bash ~/.openclaw/skills/codex-imggen/scripts/batch_generate.sh \
"flat vector art style, white background (#ffffff), each icon approximately 256x256 pixels, consistent 2px gold (#d4af37) border, same lighting angle, centered subjects" \
6 \
/tmp/my-icons
This generates one combined image with all items in a grid (usually 2x3). See Batch Examples below for tested prompts.
Batch Examples (tested 2026-05-21)
All outputs are single combined images; use ImageMagick to cut apart.
RPG Icons (3x2 grid, 1024×1536)
Generate a set of 6 RPG game UI icons in a 3x2 grid (2 columns, 3 rows), all in the same flat vector art style with a white background (#ffffff). Each icon approximately 256x256 pixels in combined image. Icons: (1) sword with golden blade, (2) shield with silver surface and red cross, (3) red health potion bottle, (4) purple crystal gem, (5) golden 5-pointed star, (6) red heart. All icons share consistent 2px gold (#d4af37) border, consistent padding, same lighting angle, centered subjects.
Cyberpunk (3x2 grid, 1024×1536)
Generate a set of 6 cyberpunk game UI elements in a 3x2 grid (2 columns, 3 rows), all in the same neon glow cyberpunk style. Each element approximately 256x256 pixels in combined image. Elements: (1) circuit board chip icon, (2) glowing cyan hexagon, (3) neon sword, (4) holographic shield, (5) power battery with lightning bolt, (6) digital eye/sensor. White background, neon colors (cyan #00ffff, magenta #ff00ff, yellow #ffff00), glow effects.
Pixel Art Items (2x3 grid, 1536×1024)
Generate a set of 6 pixel art game items in a 2x3 grid (3 columns, 2 rows), authentic retro pixel style. Each item approximately 256x256 pixels in combined image. Items: (1) red potion, (2) green herb/plant, (3) blue mana crystal, (4) golden coin, (5) brown wooden chest, (6) white feather. White background, pixel perfect, 16-bit era style.
Flat Minimal Icons (3x2 grid, 1024×1536)
Generate a set of 6 flat minimalist game UI icons in a 3x2 grid (2 columns, 3 rows). Each icon approximately 256x256 pixels in combined image. Icons: (1) play button (triangle), (2) pause button (two bars), (3) settings cogwheel, (4) home button (house shape), (5) sound on (speaker with waves), (6) sound off (speaker with X). Style: ultra flat, solid colors, no outlines, modern mobile game aesthetic. Colors: flat blue (#4a90d9), flat white, flat gray on white background.
Cutting Apart Batch Output
⚠️ Layout 注意:
- 1024×1536 图片 → 2列 × 3行 → 3x2 layout(每格 512×512)
- 1536×1024 图片 → 3列 × 2行 → 2x3 layout(每格 512×341)
# ✅ 推荐:用 batch_split.py(背景透明 + 网格拆分 + alpha 抠图一气呵成)
python3 ~/.openclaw/skills/sprite-tools/scripts/batch_split.sh \
/tmp/batch.png 3x2 /tmp/icons/
# layout 格式:rows x cols,第一个数是行数(纵向),第二个数是列数(横向)
Size Accuracy Guide
Reliable:
1K/1:1/square→ 1254×12542048x1080→ 1727×911 (best 2K match)1536x1024→ 1536×1024 (exact!)2K/16:9/FHD→ 1672×9419:16→ 941×16724:3→ 1448×1086
Unreliable (avoid):
4K/3840x2160→ capped at 1672×941 (95% area loss)- Direct pixel requests like
1920x1080→ degrades to 1672×941 - Small sizes like
512x512→ 1254×1254 (huge inflation)
For precise sizes: generate with semantic description, then post-process with ffmpeg or PIL to crop/resize.
Output Location
All images saved to ~/.codex/generated_images/\x3Csession-id>/. Scripts copy latest to your output dir. Check there if no output dir specified.
Proxy
Proxy (http://127.0.0.1:1080) auto-enabled. Change PROXY variable at top of each script if your proxy differs.
Architecture
Codex CLI → Plus subscription → ~1.57MP fixed output bucket
(8 buckets: 1:1, 16:9, 3:2, 4:3, 9:16, ~17:9)
For >1.57MP: use official gpt-image-2 API (separate skill planned)
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install codex-imggen - 安装完成后,直接呼叫该 Skill 的名称或使用
/codex-imggen触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Codex Imggen 是什么?
Generate images via Codex CLI with size control and batch support. Requires: codex (npm). Proxy auto-enabled. Use generate.sh for single images, batch_genera... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 22 次。
如何安装 Codex Imggen?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install codex-imggen」即可一键安装,无需额外配置。
Codex Imggen 是免费的吗?
是的,Codex Imggen 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Codex Imggen 支持哪些平台?
Codex Imggen 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Codex Imggen?
由 AxelHu(@axelhu)开发并维护,当前版本 v1.0.1。