nano-banana-pro

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nano Banana Pro Image Generation & Editing

Nano Banana Pro 图片生成与编辑

Generate new images or edit existing ones using Google's Nano Banana Pro API (Gemini 3 Pro Image).
使用Google的Nano Banana Pro API(Gemini 3 Pro Image)生成新图片或编辑现有图片。

Usage

使用方法

Run the script using absolute path (do NOT cd to skill directory first):
Generate new image:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "your image description" --filename "output-name.png" [--resolution 1K|2K|4K] [--api-key KEY]
Edit existing image:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "editing instructions" --filename "output-name.png" --input-image "path/to/input.png" [--resolution 1K|2K|4K] [--api-key KEY]
Important: Always run from the user's current working directory so images are saved where the user is working, not in the skill directory.
使用绝对路径运行脚本(请勿先切换到skill目录):
生成新图片:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "你的图片描述" --filename "输出名称.png" [--resolution 1K|2K|4K] [--api-key KEY]
编辑现有图片:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "编辑指令" --filename "输出名称.png" --input-image "输入图片路径.png" [--resolution 1K|2K|4K] [--api-key KEY]
重要提示: 始终从用户当前工作目录运行脚本,这样图片会保存到用户正在工作的位置,而非skill目录。

Resolution Options

分辨率选项

The Gemini 3 Pro Image API supports three resolutions (uppercase K required):
  • 1K (default) - ~1024px resolution
  • 2K - ~2048px resolution
  • 4K - ~4096px resolution
Map user requests to API parameters:
  • No mention of resolution →
    1K
  • "low resolution", "1080", "1080p", "1K" →
    1K
  • "2K", "2048", "normal", "medium resolution" →
    2K
  • "high resolution", "high-res", "hi-res", "4K", "ultra" →
    4K
Gemini 3 Pro Image API支持三种分辨率(K必须大写):
  • 1K(默认)- 约1024px分辨率
  • 2K - 约2048px分辨率
  • 4K - 约4096px分辨率
将用户需求映射到API参数:
  • 未提及分辨率 →
    1K
  • “低分辨率”、“1080”、“1080p”、“1K” →
    1K
  • “2K”、“2048”、“普通”、“中等分辨率” →
    2K
  • “高分辨率”、“high-res”、“hi-res”、“4K”、“超清” →
    4K

API Key

API密钥

The script checks for API key in this order:
  1. --api-key
    argument (use if user provided key in chat)
  2. GEMINI_API_KEY
    environment variable
If neither is available, the script exits with an error message.
脚本将按以下顺序查找API密钥:
  1. --api-key
    参数(如果用户在对话中提供了密钥)
  2. GEMINI_API_KEY
    环境变量
如果两者都不存在,脚本将退出并显示错误信息。

Filename Generation

文件名生成

Generate filenames with the pattern:
yyyy-mm-dd-hh-mm-ss-name.png
Format:
{timestamp}-{descriptive-name}.png
  • Timestamp: Current date/time in format
    yyyy-mm-dd-hh-mm-ss
    (24-hour format)
  • Name: Descriptive lowercase text with hyphens
  • Keep the descriptive part concise (1-5 words typically)
  • Use context from user's prompt or conversation
  • If unclear, use random identifier (e.g.,
    x9k2
    ,
    a7b3
    )
Examples:
  • Prompt "A serene Japanese garden" →
    2025-11-23-14-23-05-japanese-garden.png
  • Prompt "sunset over mountains" →
    2025-11-23-15-30-12-sunset-mountains.png
  • Prompt "create an image of a robot" →
    2025-11-23-16-45-33-robot.png
  • Unclear context →
    2025-11-23-17-12-48-x9k2.png
按照以下模式生成文件名:
yyyy-mm-dd-hh-mm-ss-name.png
格式:
{时间戳}-{描述性名称}.png
  • 时间戳:当前日期/时间,格式为
    yyyy-mm-dd-hh-mm-ss
    (24小时制)
  • 名称:小写描述性文本,用连字符连接
  • 描述性部分保持简洁(通常1-5个词)
  • 使用用户提示或对话中的上下文
  • 如果上下文不明确,使用随机标识符(例如:
    x9k2
    a7b3
示例:
  • 提示“宁静的日式庭院” →
    2025-11-23-14-23-05-japanese-garden.png
  • 提示“山间日落” →
    2025-11-23-15-30-12-sunset-mountains.png
  • 提示“创建一张机器人的图片” →
    2025-11-23-16-45-33-robot.png
  • 上下文不明确 →
    2025-11-23-17-12-48-x9k2.png

Image Editing

图片编辑

When the user wants to modify an existing image:
  1. Check if they provide an image path or reference an image in the current directory
  2. Use
    --input-image
    parameter with the path to the image
  3. The prompt should contain editing instructions (e.g., "make the sky more dramatic", "remove the person", "change to cartoon style")
  4. Common editing tasks: add/remove elements, change style, adjust colors, blur background, etc.
当用户想要修改现有图片时:
  1. 检查用户是否提供了图片路径或引用了当前目录中的图片
  2. 使用
    --input-image
    参数传入图片路径
  3. 提示语应包含编辑指令(例如:“让天空更有戏剧性”、“移除人物”、“改为卡通风格”)
  4. 常见编辑任务:添加/移除元素、更改风格、调整颜色、模糊背景等

Prompt Handling

提示语处理

For generation: Pass user's image description as-is to
--prompt
. Only rework if clearly insufficient.
For editing: Pass editing instructions in
--prompt
(e.g., "add a rainbow in the sky", "make it look like a watercolor painting")
Preserve user's creative intent in both cases.
生成图片时: 将用户的图片描述直接传递给
--prompt
。仅在描述明显不足时进行调整。
编辑图片时: 将编辑指令传递给
--prompt
(例如:“在天空中添加彩虹”、“让它看起来像水彩画”)
两种情况都要保留用户的创意意图。

Output

输出

  • Saves PNG to current directory (or specified path if filename includes directory)
  • Script outputs the full path to the generated image
  • Do not read the image back - just inform the user of the saved path
  • 将PNG图片保存到当前目录(如果文件名包含目录,则保存到指定路径)
  • 脚本会输出生成图片的完整路径
  • 请勿读取生成的图片 - 只需告知用户保存路径即可

Examples

示例

Generate new image:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "A serene Japanese garden with cherry blossoms" --filename "2025-11-23-14-23-05-japanese-garden.png" --resolution 4K
Edit existing image:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "make the sky more dramatic with storm clouds" --filename "2025-11-23-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K
生成新图片:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "带有樱花的宁静日式庭院" --filename "2025-11-23-14-23-05-japanese-garden.png" --resolution 4K
编辑现有图片:
bash
uv run ~/.claude/skills/nano-banana-pro/scripts/generate_image.py --prompt "让天空更有戏剧性,加上暴风雨云" --filename "2025-11-23-14-25-30-dramatic-sky.png" --input-image "original-photo.jpg" --resolution 2K