nanobanana
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNanobanana Image Generation
Nanobanana 图片生成
Generate and edit images using Google Gemini API.
使用Google Gemini API生成和编辑图片。
Prerequisites
前提条件
| Requirement | Setup |
|---|---|
| API Key | Export |
| Dependencies | |
| Script | |
| 要求 | 设置方式 |
|---|---|
| API密钥 | 导出 |
| 依赖库 | 执行 |
| 脚本路径 | |
Basic Usage
基本用法
| Task | Command |
|---|---|
| Generate image | |
| Edit image | |
| 任务 | 命令 |
|---|---|
| 生成图片 | |
| 编辑图片 | |
Aspect Ratios
宽高比
| Size | Ratio | Use Case |
|---|---|---|
| 1:1 | Square, logos |
| 9:16 | Portrait, stories (default) |
| 16:9 | Landscape, wallpapers |
| 2:3 | Portrait photos |
| 3:2 | Landscape photos |
| 21:9 | Ultra-wide |
Use to specify.
--size WIDTHxHEIGHT| 尺寸 | 比例 | 适用场景 |
|---|---|---|
| 1:1 | 方形图、标志 |
| 9:16 | 竖版图、故事类内容(默认) |
| 16:9 | 横版图、壁纸 |
| 2:3 | 竖版照片 |
| 3:2 | 横版照片 |
| 21:9 | 超宽屏 |
使用参数指定尺寸。
--size WIDTHxHEIGHTModels
模型
| Model | Trade-off |
|---|---|
| Higher quality (default) |
| Faster generation |
Use to specify.
--model MODEL| 模型 | 特点权衡 |
|---|---|
| 画质更高(默认) |
| 生成速度更快 |
使用参数指定模型。
--model MODELResolution
分辨率
| Resolution | Use Case |
|---|---|
| Testing, drafts (default) |
| Good quality |
| Final output, print |
Use to specify.
--resolution RES| 分辨率 | 适用场景 |
|---|---|
| 测试、草稿(默认) |
| 画质良好 |
| 最终输出、印刷 |
使用参数指定分辨率。
--resolution RESBest Practices
最佳实践
| Practice | Why |
|---|---|
| Be descriptive | Include style, mood, colors, composition |
| Use 1:1 for logos | Clean square format |
| Use 9:16 for stories | Standard mobile format |
| Use 16:9 for wallpapers | Standard widescreen |
| Start with 1K | Test before using higher resolution |
| Use flash model for iteration | Save 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
故障排查
| Issue | Solution |
|---|---|
| Script fails | Check |
| No image generated | Make prompt more specific |
| Can't read input | Verify file exists and is readable |
| Can't write output | Check directory is writable |
| 问题 | 解决方案 |
|---|---|
| 脚本运行失败 | 检查 |
| 未生成图片 | 让提示词更具体 |
| 无法读取输入文件 | 验证文件是否存在且可读取 |
| 无法写入输出文件 | 检查目标目录是否可写入 |