nanobanana

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nanobanana Image Generation

Nanobanana 图片生成

Generate and edit images using Google Gemini API.

使用Google Gemini API生成和编辑图片。

Prerequisites

前提条件

RequirementSetup
API KeyExport
GEMINI_API_KEY
or add to
~/.nanobanana.env
Dependencies
pip install google-genai Pillow python-dotenv
Script
${CLAUDE_PLUGIN_ROOT}/skills/core/nanobanana/nanobanana.py

要求设置方式
API密钥导出
GEMINI_API_KEY
环境变量,或添加至
~/.nanobanana.env
文件
依赖库执行
pip install google-genai Pillow python-dotenv
安装
脚本路径
${CLAUDE_PLUGIN_ROOT}/skills/core/nanobanana/nanobanana.py

Basic Usage

基本用法

TaskCommand
Generate image
python3 nanobanana.py --prompt "description" --output "file.png"
Edit image
python3 nanobanana.py --prompt "changes" --input source.png --output "edited.png"

任务命令
生成图片
python3 nanobanana.py --prompt "描述内容" --output "file.png"
编辑图片
python3 nanobanana.py --prompt "修改要求" --input source.png --output "edited.png"

Aspect Ratios

宽高比

SizeRatioUse Case
1024x1024
1:1Square, logos
768x1344
9:16Portrait, stories (default)
1344x768
16:9Landscape, wallpapers
832x1248
2:3Portrait photos
1248x832
3:2Landscape photos
1536x672
21:9Ultra-wide
Use
--size WIDTHxHEIGHT
to specify.

尺寸比例适用场景
1024x1024
1:1方形图、标志
768x1344
9:16竖版图、故事类内容(默认)
1344x768
16:9横版图、壁纸
832x1248
2:3竖版照片
1248x832
3:2横版照片
1536x672
21:9超宽屏
使用
--size WIDTHxHEIGHT
参数指定尺寸。

Models

模型

ModelTrade-off
gemini-3-pro-image-preview
Higher quality (default)
gemini-2.5-flash-image
Faster generation
Use
--model MODEL
to specify.

模型特点权衡
gemini-3-pro-image-preview
画质更高(默认)
gemini-2.5-flash-image
生成速度更快
使用
--model MODEL
参数指定模型。

Resolution

分辨率

ResolutionUse Case
1K
Testing, drafts (default)
2K
Good quality
4K
Final output, print
Use
--resolution RES
to specify.

分辨率适用场景
1K
测试、草稿(默认)
2K
画质良好
4K
最终输出、印刷
使用
--resolution RES
参数指定分辨率。

Best Practices

最佳实践

PracticeWhy
Be descriptiveInclude style, mood, colors, composition
Use 1:1 for logosClean square format
Use 9:16 for storiesStandard mobile format
Use 16:9 for wallpapersStandard widescreen
Start with 1KTest before using higher resolution
Use flash model for iterationSave time during drafting

实践建议原因
描述要具体包含风格、氛围、色彩、构图等细节
标志使用1:1比例干净的方形格式
故事类内容使用9:16比例标准移动端格式
壁纸使用16:9比例标准宽屏格式
先使用1K分辨率测试在使用更高分辨率前先进行测试
草稿迭代使用flash模型节省起草时间

Examples

示例

Generate landscape:
bash
python3 nanobanana.py --prompt "Mountain sunset with lake" --size 1344x768 --output "landscape.png"
Generate logo:
bash
python3 nanobanana.py --prompt "Minimalist tech logo" --size 1024x1024 --output "logo.png"
Edit existing image:
bash
python3 nanobanana.py --prompt "Add rainbow to sky" --input photo.png --output "edited.png"
High quality output:
bash
python3 nanobanana.py --prompt "Professional portrait" --resolution 2K --output "portrait.png"

生成横版风景图:
bash
python3 nanobanana.py --prompt "Mountain sunset with lake" --size 1344x768 --output "landscape.png"
生成标志:
bash
python3 nanobanana.py --prompt "Minimalist tech logo" --size 1024x1024 --output "logo.png"
编辑现有图片:
bash
python3 nanobanana.py --prompt "Add rainbow to sky" --input photo.png --output "edited.png"
高质量输出:
bash
python3 nanobanana.py --prompt "Professional portrait" --resolution 2K --output "portrait.png"

Troubleshooting

故障排查

IssueSolution
Script failsCheck
GEMINI_API_KEY
is set
No image generatedMake prompt more specific
Can't read inputVerify file exists and is readable
Can't write outputCheck directory is writable
问题解决方案
脚本运行失败检查
GEMINI_API_KEY
是否已正确设置
未生成图片让提示词更具体
无法读取输入文件验证文件是否存在且可读取
无法写入输出文件检查目标目录是否可写入