generate-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate images using Google's Nano Banana Pro (Gemini 3 Pro Image) model.
使用Google的Nano Banana Pro(Gemini 3 Pro Image)模型生成图片。
When to Use This Skill
何时使用本技能
| Use this skill when... | Use imagemagick-conversion instead when... |
|---|---|
| Producing a brand-new image from a text prompt | Converting, resizing, or compressing an existing image |
| Generating cinematic, product, or portrait artwork | Building thumbnails or batch-processing many files |
| Mixing up to five reference images into a new render | Applying deterministic transforms (rotate, crop, format) |
| Use this skill when... | Use mermaid-diagrams or d2-diagrams instead when... |
|---|---|
| The output is a photographic or illustrative image | The output is a flowchart, sequence, or architecture diagram |
| Quality settings (1K/2K/4K) and aspect ratio matter | Diagram-as-code rendering would be more maintainable |
| 适用场景 | 应改用imagemagick-conversion的场景 |
|---|---|
| 根据文本提示生成全新图片 | 转换、调整现有图片大小或压缩现有图片 |
| 生成电影风格、产品或肖像类插画 | 生成缩略图或批量处理大量文件 |
| 将最多5张参考图融入新渲染效果 | 应用确定性变换(旋转、裁剪、格式转换) |
| 适用场景 | 应改用mermaid-diagrams或d2-diagrams的场景 |
|---|---|
| 输出为摄影或插画类图片 | 输出为流程图、序列图或架构图 |
| 需关注画质设置(1K/2K/4K)和宽高比 | 采用代码化渲染图表更易维护 |
Arguments
参数
- {{arg:1}} (required): Image description
- --aspect: Aspect ratio (,
1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9) - default:21:916:9 - --resolution: Image resolution (,
1K,2K) - default:4K2K - --reference: Path to reference image (repeatable, max 5)
- --output: Custom output path
- {{arg:1}}(必填):图片描述
- --aspect:宽高比(,
1:1,2:3,3:2,3:4,4:3,4:5,5:4,9:16,16:9)- 默认值:21:916:9 - --resolution:图片分辨率(,
1K,2K)- 默认值:4K2K - --reference:参考图路径(可重复使用,最多5张)
- --output:自定义输出路径
Environment Requirements
环境要求
Verify API key is set:
bash
echo "API Key: ${GOOGLE_API_KEY:+SET}${GEMINI_API_KEY:+SET}"If not set, get one from: https://aistudio.google.com/apikey
验证API密钥是否已设置:
bash
echo "API Key: ${GOOGLE_API_KEY:+SET}${GEMINI_API_KEY:+SET}"若未设置,请从以下地址获取:https://aistudio.google.com/apikey
Usage Examples
使用示例
/generate-image "A beautiful mountain landscape at sunset"
/generate-image "Product photo on white background" --aspect 1:1 --resolution 4K
/generate-image "Portrait photo" --aspect 3:4
/generate-image "Cinematic scene" --aspect 21:9
/generate-image "Similar style" --reference existing_image.png/generate-image "A beautiful mountain landscape at sunset"
/generate-image "Product photo on white background" --aspect 1:1 --resolution 4K
/generate-image "Portrait photo" --aspect 3:4
/generate-image "Cinematic scene" --aspect 21:9
/generate-image "Similar style" --reference existing_image.pngTask Workflow
任务流程
-
Parse arguments:
- Extract prompt from {{arg:1}}
- Identify aspect ratio, resolution, and reference images
-
Build command:bash
uv run python .claude/scripts/nano_banana_pro.py \ "{{arg:1}}" \ --aspect {{aspect|default:"16:9"}} \ --resolution {{resolution|default:"2K"}} \ {{reference_flags}} -
Execute generation:bash
uv run python .claude/scripts/nano_banana_pro.py "PROMPT" --aspect RATIO --resolution SIZE -
Report results:
- Show path to generated image
- Note any reference images used
- Offer next steps (regenerate, different aspect, etc.)
-
解析参数:
- 从{{arg:1}}中提取提示文本
- 识别宽高比、分辨率和参考图
-
构建命令:bash
uv run python .claude/scripts/nano_banana_pro.py \ "{{arg:1}}" \ --aspect {{aspect|default:"16:9"}} \ --resolution {{resolution|default:"2K"}} \ {{reference_flags}} -
执行生成:bash
uv run python .claude/scripts/nano_banana_pro.py "PROMPT" --aspect RATIO --resolution SIZE -
反馈结果:
- 显示生成图片的路径
- 记录使用的参考图
- 提供后续操作选项(重新生成、更换宽高比等)
Output
输出
Default output:
./generated/image_YYYYMMDD_HHMMSS.pngCustom output with :
--output/generate-image "Scene" --output custom_name.png默认输出路径:
./generated/image_YYYYMMDD_HHMMSS.png使用自定义输出:
--output/generate-image "Scene" --output custom_name.pngReference Images
参考图说明
Reference images help maintain consistency:
- Use existing images as style references
- Keep subjects consistent across generations
- Match artistic styles
When using references, describe the relationship:
- "Similar style to the reference"
- "This person in a different setting"
- "Same product, different angle"
Maximum 5 reference images per generation.
参考图有助于保持一致性:
- 将现有图片作为风格参考
- 在多次生成中保持主体一致
- 匹配艺术风格
使用参考图时,请描述关联关系:
- "与参考图风格相似"
- "同一人物在不同场景中"
- "同一产品,不同角度"
每次生成最多支持5张参考图。
Aspect Ratio Quick Reference
宽高比速查
| Use Case | Ratio |
|---|---|
| Square/Instagram | 1:1 |
| Portrait | 3:4, 9:16 |
| Landscape | 16:9 |
| Ultrawide | 21:9 |
| Photo | 3:2, 4:3 |
| 使用场景 | 比例 |
|---|---|
| 方形/Instagram | 1:1 |
| 竖版肖像 | 3:4, 9:16 |
| 横版风景 | 16:9 |
| 超宽屏 | 21:9 |
| 摄影常用 | 3:2, 4:3 |
Resolution Quick Reference
分辨率速查
| Use Case | Resolution |
|---|---|
| Preview | 1K |
| Standard | 2K |
| High quality | 4K |
| 使用场景 | 分辨率 |
|---|---|
| 预览用 | 1K |
| 标准画质 | 2K |
| 高质量 | 4K |
Error Handling
错误处理
- No API key: Set or
GOOGLE_API_KEYGEMINI_API_KEY - Generation failed: Simplify prompt or reduce references
- Rate limited: Wait and retry
- 无API密钥:设置或
GOOGLE_API_KEYGEMINI_API_KEY - 生成失败:简化提示文本或减少参考图数量
- 请求受限:等待后重试