gpt-image-skill

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GPT Image Skill

GPT Image Skill

Generate or edit images using OpenAI's GPT Image models through a bundled Python script.
通过内置的Python脚本,使用OpenAI的GPT Image模型生成或编辑图片。

Requirements

要求

  1. OPENAI_API_KEY: Must be configured in
    ~/.gpt-image.env
    or
    export OPENAI_API_KEY=<your-key>
  2. OPENAI_API_BASE (optional): Custom API base URL for compatible endpoints (e.g. Azure OpenAI, proxies). Set in
    ~/.gpt-image.env
    or export it.
  3. Python3 with dependencies: openai, Pillow. Install via
    python3 -m pip install -r ${CLAUDE_SKILL_DIR}/requirements.txt
    if not installed yet.
  4. Executable:
    ${CLAUDE_SKILL_DIR}/gpt_image.py
  1. OPENAI_API_KEY:必须在
    ~/.gpt-image.env
    中配置,或通过
    export OPENAI_API_KEY=<your-key>
    设置
  2. OPENAI_API_BASE(可选):兼容端点的自定义API基础URL(例如Azure OpenAI、代理)。在
    ~/.gpt-image.env
    中设置或通过export命令配置。
  3. Python3及依赖库:openai、Pillow。如果尚未安装,可通过
    python3 -m pip install -r ${CLAUDE_SKILL_DIR}/requirements.txt
    安装。
  4. 可执行文件
    ${CLAUDE_SKILL_DIR}/gpt_image.py

Instructions

使用说明

For image generation

图片生成

  1. Ask the user for:
    • What they want to create (the prompt)
    • Desired size (optional, defaults to 1024x1024)
    • Output filename (optional, auto-generates UUID-based name if not specified)
    • Model preference (optional, defaults to gpt-image-2)
    • Quality (optional, defaults to auto)
    • Number of images (optional, defaults to 1)
  2. Run the script:
    bash
    python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "description of image" --output "filename.png"
  3. Show the user the saved image path when complete.
  1. 向用户确认以下信息:
    • 需要创建的内容(提示词)
    • 期望尺寸(可选,默认1024x1024)
    • 输出文件名(可选,未指定时自动生成基于UUID的名称)
    • 模型偏好(可选,默认gpt-image-2)
    • 画质(可选,默认auto)
    • 生成图片数量(可选,默认1)
  2. 运行脚本:
    bash
    python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "description of image" --output "filename.png"
  3. 完成后告知用户保存的图片路径。

For image editing

图片编辑

  1. Ask the user for:
    • Input image file(s) to edit (up to 3)
    • What changes they want (the prompt)
    • Output filename (optional)
  2. Run with input images:
    bash
    python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit --prompt "editing instructions" --input image1.png image2.png --output "edited.png"
  1. 向用户确认以下信息:
    • 待编辑的输入图片文件(最多3张)
    • 需要修改的内容(提示词)
    • 输出文件名(可选)
  2. 传入输入图片运行脚本:
    bash
    python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit --prompt "editing instructions" --input image1.png image2.png --output "edited.png"

Available Options

可用选项

Models (--model)

模型(--model)

  • gpt-image-2
    (default) — Latest model with strong instruction following, text rendering, and broad world knowledge
  • gpt-image-1.5
    — Mid-tier model
  • gpt-image-1
    — First-generation GPT image model
  • gpt-image-1-mini
    — Lightweight, faster generation
  • gpt-image-2
    (默认)——最新模型,具备出色的指令遵循能力、文本渲染效果和广泛的知识覆盖
  • gpt-image-1.5
    ——中端模型
  • gpt-image-1
    ——第一代GPT图像模型
  • gpt-image-1-mini
    ——轻量型模型,生成速度更快

Sizes (--size)

尺寸(--size)

  • 1024x1024
    (default) — Square
  • 1024x1536
    — Portrait (2:3)
  • 1536x1024
    — Landscape (3:2)
  • auto
    — Let the model decide
  • 1024x1024
    (默认)——正方形
  • 1024x1536
    ——竖版(2:3)
  • 1536x1024
    ——横版(3:2)
  • auto
    ——由模型决定

Quality (--quality)

画质(--quality)

  • auto
    (default) — Model decides optimal quality
  • high
    — Higher detail, slower
  • medium
    — Balanced
  • low
    — Fastest
  • auto
    (默认)——模型自动选择最优画质
  • high
    ——高细节,速度较慢
  • medium
    ——平衡型
  • low
    ——速度最快

Output Format (--format)

输出格式(--format)

  • png
    (default) — Lossless
  • jpeg
    — Smaller file size
  • webp
    — Modern format, good compression
  • png
    (默认)——无损格式
  • jpeg
    ——文件体积更小
  • webp
    ——现代格式,压缩效果好

Background (--background)

背景(--background)

  • auto
    (default) — Model decides
  • transparent
    — Transparent background (png/webp only)
  • opaque
    — Solid background
  • auto
    (默认)——由模型决定
  • transparent
    ——透明背景(仅png/webp格式支持)
  • opaque
    ——纯色背景

Other Options

其他选项

  • --n <count>
    — Number of images to generate (default: 1)
  • --output <filename>
    — Output filename (default: auto-generated)
  • --n <count>
    ——生成图片数量(默认:1)
  • --output <filename>
    ——输出文件名(默认:自动生成)

Examples

示例

Generate a simple image

生成简单图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "A serene mountain landscape at sunset with a lake"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "A serene mountain landscape at sunset with a lake"

Generate with specific size and output

指定尺寸和输出文件名生成

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Modern minimalist logo for a tech startup" \
  --size 1024x1024 \
  --quality high \
  --output "logo.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Modern minimalist logo for a tech startup" \
  --size 1024x1024 \
  --quality high \
  --output "logo.png"

Generate landscape image

生成横版图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Futuristic cityscape with flying cars" \
  --size 1536x1024 \
  --output "cityscape.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Futuristic cityscape with flying cars" \
  --size 1536x1024 \
  --output "cityscape.png"

Generate with transparent background

生成透明背景图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "A cute cartoon cat mascot" \
  --background transparent \
  --format png \
  --output "mascot.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "A cute cartoon cat mascot" \
  --background transparent \
  --format png \
  --output "mascot.png"

Generate multiple images

生成多张图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Abstract art in the style of Kandinsky" \
  --n 3 \
  --output "art.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Abstract art in the style of Kandinsky" \
  --n 3 \
  --output "art.png"

Edit existing images

编辑现有图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit \
  --prompt "Add a rainbow in the sky" \
  --input photo.png \
  --output "photo-with-rainbow.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit \
  --prompt "Add a rainbow in the sky" \
  --input photo.png \
  --output "photo-with-rainbow.png"

Combine multiple reference images

合并多张参考图片

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit \
  --prompt "Create a gift basket containing all items shown" \
  --input item1.png item2.png item3.png \
  --output "gift-basket.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit \
  --prompt "Create a gift basket containing all items shown" \
  --input item1.png item2.png item3.png \
  --output "gift-basket.png"

Use a different model

使用其他模型

bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Detailed portrait of a cat in watercolor style" \
  --model gpt-image-1 \
  --output "cat-portrait.png"
bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py \
  --prompt "Detailed portrait of a cat in watercolor style" \
  --model gpt-image-1 \
  --output "cat-portrait.png"

Error Handling

错误处理

If the script fails:
  • Check that
    OPENAI_API_KEY
    is exported
  • If using a custom endpoint, verify
    OPENAI_API_BASE
    is correct
  • Verify input image files exist and are readable (for editing)
  • Ensure the output directory is writable
  • Check that the model name is valid
如果脚本运行失败:
  • 检查
    OPENAI_API_KEY
    是否已导出
  • 如果使用自定义端点,确认
    OPENAI_API_BASE
    配置正确
  • 验证输入图片文件是否存在且可读(编辑场景)
  • 确保输出目录可写入
  • 检查模型名称是否有效

Best Practices

最佳实践

  1. Be descriptive in prompts — include style, mood, colors, composition details
  2. For logos/icons, use square size (1024x1024) with transparent background
  3. For social media, use portrait (1024x1536) for stories or square for posts
  4. For wallpapers/headers, use landscape (1536x1024)
  5. Use
    high
    quality for final output,
    auto
    for quick iterations
  6. GPT Image models excel at text rendering — include text in prompts when needed
  7. For editing, provide clear instructions about what to change and what to keep
  1. 提示词要详细——包含风格、氛围、颜色、构图细节
  2. 生成标志/图标时,使用正方形尺寸(1024x1024)并设置透明背景
  3. 社交媒体场景中,故事类内容用竖版(1024x1536),帖子类用正方形
  4. 壁纸/页眉类内容用横版(1536x1024)
  5. 最终输出使用
    high
    画质,快速迭代使用
    auto
  6. GPT Image模型擅长文本渲染——需要时可在提示词中包含文本内容
  7. 编辑场景中,明确说明需要修改和保留的内容