gpt-image-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGPT 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
要求
- OPENAI_API_KEY: Must be configured in or
~/.gpt-image.envexport OPENAI_API_KEY=<your-key> - OPENAI_API_BASE (optional): Custom API base URL for compatible endpoints (e.g. Azure OpenAI, proxies). Set in or export it.
~/.gpt-image.env - Python3 with dependencies: openai, Pillow. Install via if not installed yet.
python3 -m pip install -r ${CLAUDE_SKILL_DIR}/requirements.txt - Executable:
${CLAUDE_SKILL_DIR}/gpt_image.py
- OPENAI_API_KEY:必须在中配置,或通过
~/.gpt-image.env设置export OPENAI_API_KEY=<your-key> - OPENAI_API_BASE(可选):兼容端点的自定义API基础URL(例如Azure OpenAI、代理)。在中设置或通过export命令配置。
~/.gpt-image.env - Python3及依赖库:openai、Pillow。如果尚未安装,可通过安装。
python3 -m pip install -r ${CLAUDE_SKILL_DIR}/requirements.txt - 可执行文件:
${CLAUDE_SKILL_DIR}/gpt_image.py
Instructions
使用说明
For image generation
图片生成
-
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)
-
Run the script:bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "description of image" --output "filename.png" -
Show the user the saved image path when complete.
-
向用户确认以下信息:
- 需要创建的内容(提示词)
- 期望尺寸(可选,默认1024x1024)
- 输出文件名(可选,未指定时自动生成基于UUID的名称)
- 模型偏好(可选,默认gpt-image-2)
- 画质(可选,默认auto)
- 生成图片数量(可选,默认1)
-
运行脚本:bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py --prompt "description of image" --output "filename.png" -
完成后告知用户保存的图片路径。
For image editing
图片编辑
-
Ask the user for:
- Input image file(s) to edit (up to 3)
- What changes they want (the prompt)
- Output filename (optional)
-
Run with input images:bash
python3 ${CLAUDE_SKILL_DIR}/gpt_image.py edit --prompt "editing instructions" --input image1.png image2.png --output "edited.png"
-
向用户确认以下信息:
- 待编辑的输入图片文件(最多3张)
- 需要修改的内容(提示词)
- 输出文件名(可选)
-
传入输入图片运行脚本: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)
- (default) — Latest model with strong instruction following, text rendering, and broad world knowledge
gpt-image-2 - — Mid-tier model
gpt-image-1.5 - — First-generation GPT image model
gpt-image-1 - — Lightweight, faster generation
gpt-image-1-mini
- (默认)——最新模型,具备出色的指令遵循能力、文本渲染效果和广泛的知识覆盖
gpt-image-2 - ——中端模型
gpt-image-1.5 - ——第一代GPT图像模型
gpt-image-1 - ——轻量型模型,生成速度更快
gpt-image-1-mini
Sizes (--size)
尺寸(--size)
- (default) — Square
1024x1024 - — Portrait (2:3)
1024x1536 - — Landscape (3:2)
1536x1024 - — Let the model decide
auto
- (默认)——正方形
1024x1024 - ——竖版(2:3)
1024x1536 - ——横版(3:2)
1536x1024 - ——由模型决定
auto
Quality (--quality)
画质(--quality)
- (default) — Model decides optimal quality
auto - — Higher detail, slower
high - — Balanced
medium - — Fastest
low
- (默认)——模型自动选择最优画质
auto - ——高细节,速度较慢
high - ——平衡型
medium - ——速度最快
low
Output Format (--format)
输出格式(--format)
- (default) — Lossless
png - — Smaller file size
jpeg - — Modern format, good compression
webp
- (默认)——无损格式
png - ——文件体积更小
jpeg - ——现代格式,压缩效果好
webp
Background (--background)
背景(--background)
- (default) — Model decides
auto - — Transparent background (png/webp only)
transparent - — Solid background
opaque
- (默认)——由模型决定
auto - ——透明背景(仅png/webp格式支持)
transparent - ——纯色背景
opaque
Other Options
其他选项
- — Number of images to generate (default: 1)
--n <count> - — Output filename (default: auto-generated)
--output <filename>
- ——生成图片数量(默认:1)
--n <count> - ——输出文件名(默认:自动生成)
--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 is exported
OPENAI_API_KEY - If using a custom endpoint, verify is correct
OPENAI_API_BASE - 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
最佳实践
- Be descriptive in prompts — include style, mood, colors, composition details
- For logos/icons, use square size (1024x1024) with transparent background
- For social media, use portrait (1024x1536) for stories or square for posts
- For wallpapers/headers, use landscape (1536x1024)
- Use quality for final output,
highfor quick iterationsauto - GPT Image models excel at text rendering — include text in prompts when needed
- For editing, provide clear instructions about what to change and what to keep
- 提示词要详细——包含风格、氛围、颜色、构图细节
- 生成标志/图标时,使用正方形尺寸(1024x1024)并设置透明背景
- 社交媒体场景中,故事类内容用竖版(1024x1536),帖子类用正方形
- 壁纸/页眉类内容用横版(1536x1024)
- 最终输出使用画质,快速迭代使用
highauto - GPT Image模型擅长文本渲染——需要时可在提示词中包含文本内容
- 编辑场景中,明确说明需要修改和保留的内容