图像生成

tymoshenko-dmytro2026-10-25查看 281复制 44

通过捆绑的仅标准库 CLI 使用 OpenAI gpt-image-2 生成或编辑营销图片——博客封面、落地页插图、广告视觉、社交图形、产品 mockup、inpainting 和多图合成——根据用户需要草稿还是最终资产来选择质量(low / medium / high),并检查每个渲染出的文字。适用于有人要求创建、绘制、渲染、编辑或 inpaint 图片时。触发词:“generate an image”、“make a cover”、“illustration for the land……”

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md4751 chars
---
name: image-gen
description: >-
  Generate or edit marketing images with OpenAI gpt-image-2 through a bundled stdlib-only CLI — blog covers, landing-page illustrations, ad visuals, social graphics, product mockups, inpainting and multi-image compositions — choosing quality (low / medium / high) by whether the user needs drafts or a final asset, and checking every rendered word. Use whenever someone asks to create, draw, render, edit or inpaint an image. Triggers: "generate an image", "make a cover", "illustration for the landing", "edit this picture", "inpaint".
---

# Image generation — gpt-image-2

`scripts/img.py` wraps OpenAI's image API. Python stdlib only, nothing to install. Default model `gpt-image-2`; OpenAI now recommends the GPT Image 2.5 models for new work (`--model gpt-image-2.5-flare`, or set `IMG_MODEL`) — same per-token price, plus `xhigh` and `max` quality. Try one on a draft before switching a whole project.

**Key:** `OPENAI_API_KEY`, from the environment or `~/.config/marketing-agent-kit/.env`. Setup: `connections/openai-images-api.md`, or run the `connect` skill.

```bash
IMG="python3 ${CLAUDE_SKILL_DIR}/scripts/img.py"
$IMG "a watercolor cat on a windowsill" -q low -o drafts/cat.png
$IMG edit "make it nighttime" -i photo.png -o out.png
$IMG edit "fill the masked area with sky" -i photo.png -m mask.png -o out.png
$IMG edit "compose these two into one scene" -i a.png -i b.png -o combined.png
```

`img.py <prompt>` without a subcommand means `generate`.

## Quality is the main cost lever

The default is `high`. Quality changes the price roughly 35×, so downgrade on purpose for exploration. Approximate prices for 1024×1024 (OpenAI pricing, autumn 2026; landscape 1536×1024 is slightly cheaper):

| `-q` | ~price | Use for |
|---|---|---|
| `low` | ~$0.006 | brainstorming many variants, mood boards, "show me 5 ideas" |
| `medium` | ~$0.053 | working drafts, "is this the right direction?" |
| `high` | ~$0.211 | final assets that will be published or shown (default) |

**Rule:** more than three images of one concept for the user to pick from → `low` or `medium`. Re-render the chosen one at `high`. Say it out loud: "Rendering 4 drafts at low quality — pick one and I'll re-render it at high."

## Flags

- `-o PATH` — output file (default `img-<timestamp>.png` in the current folder). With `-n > 1`: `name-1.png`, `name-2.png`, …
- `-s SIZE` — `auto` (default) | `1024x1024` | `1536x1024` (landscape) | `1024x1536` (portrait) | other sizes: edges in multiples of 16, up to 3840 px, aspect ratio up to 3:1 (above 2560×1440 is experimental).
- `-f png|jpeg|webp`, `--compression 0-100` (jpeg / webp only).
- `-n N` — variants in one call.
- `--background opaque|transparent|auto` — for a transparent PNG use a GPT Image 2.5 model: `--model gpt-image-2.5-flare --background transparent -f png`. `gpt-image-2` rejects `transparent` with HTTP 400 (tested 2026-10-01, although the API reference calls it a preview).
- `--moderation low|auto` — `low` only when the user asks and the content is benign.
- `--model` — default `gpt-image-2`; pin a dated snapshot when the user needs reproducibility.

Edits: without `-m` the whole image is rewritten from the prompt and inputs. With `-m mask.png` only the transparent area of the mask changes (the mask needs an alpha channel and the same size and format as the input, under 50 MB).

New OpenAI accounts may need **API Organization Verification** before GPT Image models work, and the lowest usage tier is limited to about 5 images per minute. Several `-i` flags compose several references into one image.

## Art direction rules for marketing images

Read `references/art-direction.md` before writing a prompt for anything that will be published. The core:

- **The picture illustrates the actual content**, literally. A generic flat-lay of blurred papers next to a list of bonuses is filler; the same documents with their real short titles on them is an illustration.
- **At most two pieces of text in an image**, short ones, and **check every letter** of every rendered word before showing it. Misspelled text in a generated image is the most common reason it gets rejected.
- **A metaphor has to be literally true** to what the copy says. If it isn't, use the product itself.

## After generating

- Print the absolute output path.
- If the project keeps images in a folder (`assets/`, `public/images/`), generate there.
- Look at the result yourself before presenting it: text spelling, extra fingers, cut-off objects, wrong brand colours.

## Adapt it

- Add your brand to `references/art-direction.md`: palette (hex codes), what your product UI looks like, two or three reference images you like and why. Prompts that quote these come out on-brand.
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧