generate-image

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Generate 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 promptConverting, resizing, or compressing an existing image
Generating cinematic, product, or portrait artworkBuilding thumbnails or batch-processing many files
Mixing up to five reference images into a new renderApplying deterministic transforms (rotate, crop, format)
Use this skill when...Use mermaid-diagrams or d2-diagrams instead when...
The output is a photographic or illustrative imageThe output is a flowchart, sequence, or architecture diagram
Quality settings (1K/2K/4K) and aspect ratio matterDiagram-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
    ,
    21:9
    ) - default:
    16:9
  • --resolution: Image resolution (
    1K
    ,
    2K
    ,
    4K
    ) - default:
    2K
  • --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:9
    )- 默认值:
    16:9
  • --resolution:图片分辨率(
    1K
    ,
    2K
    ,
    4K
    )- 默认值:
    2K
  • --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.png

Task Workflow

任务流程

  1. Parse arguments:
    • Extract prompt from {{arg:1}}
    • Identify aspect ratio, resolution, and reference images
  2. 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}}
  3. Execute generation:
    bash
    uv run python .claude/scripts/nano_banana_pro.py "PROMPT" --aspect RATIO --resolution SIZE
  4. Report results:
    • Show path to generated image
    • Note any reference images used
    • Offer next steps (regenerate, different aspect, etc.)
  1. 解析参数:
    • 从{{arg:1}}中提取提示文本
    • 识别宽高比、分辨率和参考图
  2. 构建命令:
    bash
    uv run python .claude/scripts/nano_banana_pro.py \
      "{{arg:1}}" \
      --aspect {{aspect|default:"16:9"}} \
      --resolution {{resolution|default:"2K"}} \
      {{reference_flags}}
  3. 执行生成:
    bash
    uv run python .claude/scripts/nano_banana_pro.py "PROMPT" --aspect RATIO --resolution SIZE
  4. 反馈结果:
    • 显示生成图片的路径
    • 记录使用的参考图
    • 提供后续操作选项(重新生成、更换宽高比等)

Output

输出

Default output:
./generated/image_YYYYMMDD_HHMMSS.png
Custom output with
--output
:
/generate-image "Scene" --output custom_name.png
默认输出路径:
./generated/image_YYYYMMDD_HHMMSS.png
使用
--output
自定义输出:
/generate-image "Scene" --output custom_name.png

Reference 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 CaseRatio
Square/Instagram1:1
Portrait3:4, 9:16
Landscape16:9
Ultrawide21:9
Photo3:2, 4:3
使用场景比例
方形/Instagram1:1
竖版肖像3:4, 9:16
横版风景16:9
超宽屏21:9
摄影常用3:2, 4:3

Resolution Quick Reference

分辨率速查

Use CaseResolution
Preview1K
Standard2K
High quality4K
使用场景分辨率
预览用1K
标准画质2K
高质量4K

Error Handling

错误处理

  • No API key: Set
    GOOGLE_API_KEY
    or
    GEMINI_API_KEY
  • Generation failed: Simplify prompt or reduce references
  • Rate limited: Wait and retry
  • 无API密钥:设置
    GOOGLE_API_KEY
    GEMINI_API_KEY
  • 生成失败:简化提示文本或减少参考图数量
  • 请求受限:等待后重试