Loading...
Loading...
Compare original and translation side by side
gemini-3-pro-image-previewgemini-2.5-flash-imagegemini-3-pro-image-previewgemini-2.5-flash-imageGEMINI_API_KEYuvgoogle-genaiuvuv runpython3pip install -r <skill_dir>/requirements.txtGEMINI_API_KEYuvgoogle-genaiuvuv runpython3pip install -r <skill_dir>/requirements.txt~/Downloads/nanobanana_<timestamp>.png-o-o ~/Downloads/robot.png~/Downloads/nanobanana_<timestamp>.png-o-o ~/Downloads/robot.pnguv run <skill_dir>/scripts/generate.py "a cute robot mascot, pixel art style"uv run <skill_dir>/scripts/generate.py "a cute robot mascot, pixel art style"uv run <skill_dir>/scripts/generate.py "make the background blue" -i input.jpguv run <skill_dir>/scripts/generate.py "make the background blue" -i input.jpguv run <skill_dir>/scripts/generate.py "quick sketch of a cat" --model flashuv run <skill_dir>/scripts/generate.py "quick sketch of a cat" --model flashuv run <skill_dir>/scripts/generate.py "apply the style of the first image to the second" \
-i style_ref.png subject.jpguv run <skill_dir>/scripts/generate.py "apply the style of the first image to the second" \
-i style_ref.png subject.jpguv run <skill_dir>/scripts/generate.py "cinematic landscape" --ratio 21:9 --size 4Kuv run <skill_dir>/scripts/generate.py "cinematic landscape" --ratio 21:9 --size 4Kuv run <skill_dir>/scripts/generate.py "logo design" -o ~/Projects/brand/logo.pnguv run <skill_dir>/scripts/generate.py "logo design" -o ~/Projects/brand/logo.png| Pro (default) | Flash | |
|---|---|---|
| Speed | Slower | ~2-3x faster |
| Cost | Higher | Lower |
| Text rendering | Good | Unreliable |
| Complex scenes | Excellent | Adequate |
| Thinking mode | Yes | No |
| Best for | Final production images | Exploration, drafts, batch |
| Pro(默认) | Flash | |
|---|---|---|
| 速度 | 较慢 | 快2-3倍 |
| 成本 | 较高 | 较低 |
| 文本渲染效果 | 好 | 不稳定 |
| 复杂场景处理 | 极佳 | 合格 |
| 思考模式 | 支持 | 不支持 |
| 最佳适用场景 | 最终生产用图 | 探索、草稿、批量生成 |
scripts/generate.pyscripts/generate.pyUsage: generate.py [OPTIONS] PROMPT
Arguments:
PROMPT Text prompt for image generation
Options:
-o, --output PATH Output file path (default: ~/Downloads/nanobanana_<timestamp>.png)
-i, --input PATH... Input image(s) for editing / reference (up to 14)
-m, --model MODEL Model: 'pro' (default), 'flash', or full model ID
-r, --ratio RATIO Aspect ratio (1:1, 16:9, 9:16, 21:9, etc.)
-s, --size SIZE Image size: 1K, 2K, or 4K (default: standard)
--search Enable Google Search grounding for accuracy
--retries N Max retries on rate limit (default: 3)
-v, --verbose Show detailed output1:12:33:23:44:34:55:49:1616:921:91K2K4KUsage: generate.py [OPTIONS] PROMPT
Arguments:
PROMPT 图像生成的文本提示词
Options:
-o, --output PATH 输出文件路径(默认:~/Downloads/nanobanana_<timestamp>.png)
-i, --input PATH... 用于编辑/参考的输入图像(最多14张)
-m, --model MODEL 模型:'pro'(默认)、'flash',或完整模型ID
-r, --ratio RATIO 宽高比(1:1、16:9、9:16、21:9等)
-s, --size SIZE 图像尺寸:1K、2K或4K(默认:标准尺寸)
--search 启用Google Search grounding提升内容准确性
--retries N 速率限制触发后的最大重试次数(默认:3)
-v, --verbose 显示详细输出1:12:33:23:44:34:55:49:1616:921:91K2K4Kscripts/batch_generate.pyscripts/batch_generate.pyUsage: batch_generate.py [OPTIONS] PROMPT
Arguments:
PROMPT Text prompt for image generation
Options:
-n, --count N Number of images to generate (default: 10)
-d, --dir PATH Output directory (default: ~/Downloads)
-p, --prefix STR Filename prefix (default: "image")
-m, --model MODEL Model: 'pro' (default), 'flash', or full model ID
-r, --ratio RATIO Aspect ratio
-s, --size SIZE Image size (1K/2K/4K)
--search Enable Google Search grounding
--retries N Max retries per image on rate limit (default: 3)
--delay SECONDS Delay between generations (default: 3)
--parallel N Concurrent requests (default: 1, max recommended: 5)
-q, --quiet Suppress progress outputuv run <skill_dir>/scripts/batch_generate.py "pixel art logo" -n 20 --model flash -d ./logos -p logoUsage: batch_generate.py [OPTIONS] PROMPT
Arguments:
PROMPT 图像生成的文本提示词
Options:
-n, --count N 要生成的图像数量(默认:10)
-d, --dir PATH 输出目录(默认:~/Downloads)
-p, --prefix STR 文件名前缀(默认:"image")
-m, --model MODEL 模型:'pro'(默认)、'flash',或完整模型ID
-r, --ratio RATIO 宽高比
-s, --size SIZE 图像尺寸(1K/2K/4K)
--search 启用Google Search grounding
--retries N 单张图像速率限制触发后的最大重试次数(默认:3)
--delay SECONDS 两次生成之间的延迟(默认:3秒)
--parallel N 并发请求数(默认:1,推荐最大值:5)
-q, --quiet 关闭进度输出uv run <skill_dir>/scripts/batch_generate.py "pixel art logo" -n 20 --model flash -d ./logos -p logoNote: When importing as a Python module,must be available in the calling script's environment. If usinggoogle-genai, add a PEP 723uv runblock to your own script (see example in Pattern 2 below).dependencies
import sys
from pathlib import Path
sys.path.insert(0, str(Path("<skill_dir>/scripts")))
from generate import generate_image, edit_image, batch_generate注意: 作为Python模块导入时,调用脚本的环境中必须已安装。如果使用google-genai,请在你自己的脚本中添加PEP 723uv run块(参见下方模式2的示例)。dependencies
import sys
from pathlib import Path
sys.path.insert(0, str(Path("<skill_dir>/scripts")))
from generate import generate_image, edit_image, batch_generateundefinedundefined{
"success": True, # or False
"path": "/path/to/output.png", # or None on failure
"error": None, # or error message string
"metadata": {
"model": "gemini-3-pro-image-preview",
"prompt": "...",
"aspect_ratio": "16:9",
"image_size": "4K",
"use_search": False,
"input_images": None, # or list of paths
"text_response": "...", # optional text from model
"thinking": "...", # Pro model reasoning (when available)
"timestamp": "2025-01-26T...",
}
}{
"success": True, # 失败则为False
"path": "/path/to/output.png", # 失败则为None
"error": None, # 失败则为错误信息字符串
"metadata": {
"model": "gemini-3-pro-image-preview",
"prompt": "...",
"aspect_ratio": "16:9",
"image_size": "4K",
"use_search": False,
"input_images": None, # 或输入图像路径列表
"text_response": "...", # 模型返回的可选文本内容
"thinking": "...", # Pro模型的推理过程(如果可用)
"timestamp": "2025-01-26T...",
}
}undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedfrom batch_generate import batch_generate
def on_progress(completed, total, result):
print(f"Progress: {completed}/{total}")
results = batch_generate(
prompt="logo concept",
count=20,
output_dir="./logos",
prefix="logo",
model="flash",
aspect_ratio="1:1",
on_progress=on_progress,
)
successful = [r for r in results if r["success"]]from batch_generate import batch_generate
def on_progress(completed, total, result):
print(f"进度:{completed}/{total}")
results = batch_generate(
prompt="logo concept",
count=20,
output_dir="./logos",
prefix="logo",
model="flash",
aspect_ratio="1:1",
on_progress=on_progress,
)
successful = [r for r in results if r["success"]]from generate import generate_imagefrom generate import generate_image
The full sequential generation patterns are documented in the [Sequential Generation](#sequential-generation) section above.
完整的顺序生成模式已记录在上文[顺序生成](#顺序生成)部分。| Variable | Description | Default |
|---|---|---|
| Google Gemini API key | Required |
| Default output directory | |
| 变量名 | 说明 | 默认值 |
|---|---|---|
| Google Gemini API密钥 | 必填 |
| 默认输出目录 | |
--search--search-i-iuv run <skill_dir>/scripts/generate.py \
"modern flat illustration style, warm earth tones, soft gradients, clean lines, \
minimal detail, cozy atmosphere" \
--model pro -o anchor.pnguv run <skill_dir>/scripts/generate.py \
"a laptop on a desk with coffee, matching the visual style, color palette, \
and lighting of the reference image exactly" \
-i anchor.png --model pro -o image_01.pnguv run <skill_dir>/scripts/generate.py \
"modern flat illustration style, warm earth tones, soft gradients, clean lines, \
minimal detail, cozy atmosphere" \
--model pro -o anchor.pnguv run <skill_dir>/scripts/generate.py \
"a laptop on a desk with coffee, matching the visual style, color palette, \
and lighting of the reference image exactly" \
-i anchor.png --model pro -o image_01.pnguv run <skill_dir>/scripts/generate.py \
"a friendly robot mascot with round blue body, orange antenna, large expressive eyes, \
simple geometric design, standing front-facing on white background" \
--model pro -o subject_front.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference image, now sitting at a desk typing, \
same proportions and colors, office background" \
-i subject_front.png --model pro -o subject_office.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference images, now outdoors in a park, \
same proportions and colors, waving at the viewer" \
-i subject_front.png subject_office.png --model pro -o subject_park.pnguv run <skill_dir>/scripts/generate.py \
"a friendly robot mascot with round blue body, orange antenna, large expressive eyes, \
simple geometric design, standing front-facing on white background" \
--model pro -o subject_front.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference image, now sitting at a desk typing, \
same proportions and colors, office background" \
-i subject_front.png --model pro -o subject_office.pnguv run <skill_dir>/scripts/generate.py \
"the same robot character from the reference images, now outdoors in a park, \
same proportions and colors, waving at the viewer" \
-i subject_front.png subject_office.png --model pro -o subject_park.png-i-i-i-i--model flash--model flash--delay 5--parallel--delay 5--parallelcurl -LsSf https://astral.sh/uv/install.sh | shbrew install uvuv runpython3pip install -r <skill_dir>/requirements.txtGEMINI_API_KEYcurl -LsSf https://astral.sh/uv/install.sh | shbrew install uvuv runpython3pip install -r <skill_dir>/requirements.txtGEMINI_API_KEY