Nanobanana Image Generation Skill
Generate or edit images using Google Gemini API through the nanobanana tool.
Requirements
- 1. GEMINIAPIKEY: Must be configured in
~/.nanobanana.env or INLINECODE1 - Python3 with depedent packages installed: google-genai, Pillow, python-dotenv. They could be installed via
python3 -m pip install -r ${CLAUDE_PLUGIN_ROOT}/skills/nanobanana-skill/requirements.txt if not installed yet. - Executable: INLINECODE3
Instructions
For image generation
- 1. Ask the user for:
- What they want to create (the prompt)
- Desired aspect ratio/size (optional, defaults to 9:16 portrait)
- Output filename (optional, auto-generates UUID if not specified)
- Model preference (optional, defaults to gemini-3-pro-image-preview)
- Resolution (optional, defaults to 1K)
- 2. Run the nanobanana script with appropriate parameters:
CODEBLOCK0
- 3. Show the user the saved image path when complete
For image editing
- 1. Ask the user for:
- Input image file(s) to edit
- What changes they want (the prompt)
- Output filename (optional)
- 2. Run with input images:
CODEBLOCK1
Available Options
Aspect Ratios (--size)
- -
1024x1024 (1:1) - Square - INLINECODE5 (2:3) - Portrait
- INLINECODE6 (3:2) - Landscape
- INLINECODE7 (3:4) - Portrait
- INLINECODE8 (4:3) - Landscape
- INLINECODE9 (4:5) - Portrait
- INLINECODE10 (5:4) - Landscape
- INLINECODE11 (9:16) - Portrait (default)
- INLINECODE12 (16:9) - Landscape
- INLINECODE13 (21:9) - Ultra-wide
Models (--model)
- -
gemini-3-pro-image-preview (default) - Higher quality - INLINECODE15 - Faster generation
Resolution (--resolution)
- -
1K (default) - INLINECODE17
- INLINECODE18
Examples
Generate a simple image
CODEBLOCK2
Generate with specific size and output
CODEBLOCK3
Generate landscape image with high resolution
CODEBLOCK4
Edit existing images
CODEBLOCK5
Use faster model
CODEBLOCK6
Error Handling
If the script fails:
- - Check that
GEMINI_API_KEY is exported or set in ~/.nanobanana.env - Verify input image files exist and are readable
- Ensure the output directory is writable
- If no image is generated, try making the prompt more specific about wanting an image
Best Practices
- 1. Be descriptive in prompts - include style, mood, colors, composition
- For logos/graphics, use square aspect ratio (1024x1024)
- For social media posts, use 9:16 for stories or 1:1 for posts
- For wallpapers, use 16:9 or 21:9
- Start with 1K resolution for testing, upgrade to 2K/4K for final output
- Use gemini-3-pro-image-preview for best quality, gemini-2.5-flash-image for speed
Nanobanana 图像生成技能
通过 nanobanana 工具使用 Google Gemini API 生成或编辑图像。
要求
- 1. GEMINIAPIKEY:必须在 ~/.nanobanana.env 中配置,或通过 export GEMINIAPIKEY=<你的API密钥> 设置
- 已安装依赖包的 Python3:google-genai、Pillow、python-dotenv。如果尚未安装,可通过 python3 -m pip install -r ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/requirements.txt 安装
- 可执行文件:${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py
使用说明
图像生成
- 1. 向用户询问:
- 想要创建的内容(提示词)
- 期望的宽高比/尺寸(可选,默认为 9:16 竖屏)
- 输出文件名(可选,未指定时自动生成 UUID)
- 模型偏好(可选,默认为 gemini-3-pro-image-preview)
- 分辨率(可选,默认为 1K)
- 2. 使用相应参数运行 nanobanana 脚本:
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py --prompt 图像描述 --output 文件名.png
- 3. 完成后向用户显示保存的图像路径
图像编辑
- 1. 向用户询问:
- 要编辑的输入图像文件
- 想要进行的修改(提示词)
- 输出文件名(可选)
- 2. 使用输入图像运行:
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py --prompt 编辑说明 --input image1.png image2.png --output 编辑后.png
可用选项
宽高比(--size)
- - 1024x1024(1:1)- 正方形
- 832x1248(2:3)- 竖屏
- 1248x832(3:2)- 横屏
- 864x1184(3:4)- 竖屏
- 1184x864(4:3)- 横屏
- 896x1152(4:5)- 竖屏
- 1152x896(5:4)- 横屏
- 768x1344(9:16)- 竖屏(默认)
- 1344x768(16:9)- 横屏
- 1536x672(21:9)- 超宽屏
模型(--model)
- - gemini-3-pro-image-preview(默认)- 更高质量
- gemini-2.5-flash-image - 更快生成
分辨率(--resolution)
示例
生成简单图像
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py --prompt 日落时分宁静的山景,带湖泊
指定尺寸和输出
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py \
--prompt 科技初创公司的现代极简标志 \
--size 1024x1024 \
--output logo.png
生成高分辨率横屏图像
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py \
--prompt 未来城市景观,带飞行汽车 \
--size 1344x768 \
--resolution 2K \
--output 城市景观.png
编辑现有图像
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py \
--prompt 在天空中加一道彩虹 \
--input 照片.png \
--output 带彩虹的照片.png
使用更快的模型
bash
python3 ${CLAUDEPLUGINROOT}/skills/nanobanana-skill/nanobanana.py \
--prompt 猫的快速素描 \
--model gemini-2.5-flash-image \
--output 猫素描.png
错误处理
如果脚本运行失败:
- - 检查 GEMINIAPIKEY 是否已导出或在 ~/.nanobanana.env 中设置
- 验证输入图像文件存在且可读
- 确保输出目录可写
- 如果未生成图像,尝试在提示词中更明确地说明需要生成图像
最佳实践
- 1. 提示词要描述详细 - 包括风格、氛围、颜色、构图
- 对于标志/图形,使用正方形宽高比(1024x1024)
- 对于社交媒体帖子,故事使用 9:16,帖子使用 1:1
- 对于壁纸,使用 16:9 或 21:9
- 测试时从 1K 分辨率开始,最终输出升级到 2K/4K
- 使用 gemini-3-pro-image-preview 获得最佳质量,使用 gemini-2.5-flash-image 获得更快速度