详细分析 ▾
运行时依赖
版本
- Initial release of nano-banana-pro skill, enabling image generation and editing via Google’s Gemini 3 Pro Image API. - Supports both text-to-image and image-to-image workflows, including prompt-based edits. - Handles 1K, 2K, and 4K resolution options with user-friendly resolution mapping. - Saves images in the current working directory using timestamped, descriptive filenames. - Flexible API key management (argument or environment variable). - Includes preflight checks, error handling guidance, and prompt templates for both generation and editing use cases.
安装命令 点击复制
技能文档
Generate new images or edit existing ones using Google's Nano Banana Pro API (Gemini 3 Pro Image).
Usage
Run the script using absolute path (do NOT cd to skill directory first):
Generate 新的 image:
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "your image description" --filename "output-name.png" [--resolution 1K|2K|4K] [--api-key KEY]
编辑 existing image:
uv run ~/.codex/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 从 用户's current working directory 所以 images saved 在哪里 用户 working, 不 在...中 skill directory.
默认 Workflow (draft → iterate → final)
Goal: fast iteration without burning time on 4K until the prompt is correct.
- Draft (1K): quick feedback 循环
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "" --filename "yyyy-mm-dd-hh-mm-ss-draft.png" --resolution 1K
- Iterate: adjust prompt 在...中 small diffs; keep filename 新的 per run
--输入框-image 对于 every iteration until 您’re happy.
- Final (4K): 仅 当...时 prompt locked
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "" --filename "yyyy-mm-dd-hh-mm-ss-final.png" --resolution 4K Resolution Options
The Gemini 3 Pro Image API supports three resolutions (uppercase K required):
- 1K (默认) - ~1024px resolution
- 2K - ~2048px resolution
- 4K - ~4096px resolution
Map user requests to API parameters:
- 否 mention 的 resolution →
1K - "low resolution", "1080", "1080p", "1K" →
1K - "2K", "2048", "normal", "medium resolution" →
2K - "high resolution", "high-res", "hi-res", "4K", "ultra" →
4K
API 键
The script checks for API key in this order:
--api-键argument (使用 如果 用户 provided 键 在...中 chat)GEMINI_API_KEYenvironment 变量
If neither is available, the script exits with an error message.
Preflight + Common Failures (fast fixes)
- Preflight:
command -v uv (必须 exist)
- test -n \"$GEMINI_API_KEY\" (或 pass --api-键)
- 如果 editing: test -f \"path/到/输入框.png\"- Common failures:
错误: 否 API 键 provided. → 设置 GEMINI_API_KEY 或 pass --api-键
- 错误 loading 输入框 image: → wrong path / unreadable file; 验证 --输入框-image points 到 real image
- “quota/权限/403” 样式 API errors → wrong 键, 否 access, 或 quota exceeded; try 不同 键/账户Filename Generation
Generate filenames with the pattern: yyyy-mm-dd-hh-mm-ss-name.png
格式: {时间戳}-{descriptive-name}.png
- 时间戳: Current 日期/时间 在...中 格式
yyyy-mm-dd-hh-mm-ss(24-hour 格式) - Name: Descriptive lowercase text 带有 hyphens
- Keep descriptive part concise (1-5 words typically)
- 使用 context 从 用户's prompt 或 conversation
- 如果 unclear, 使用 random identifier (e.g.,
x9k2,a7b3)
Examples:
- Prompt " serene Japanese garden" →
2025-11-23-14-23-05-japanese-garden.png - Prompt "sunset 在...上 mountains" →
2025-11-23-15-30-12-sunset-mountains.png - Prompt "创建 image 的 robot" →
2025-11-23-16-45-33-robot.png - Unclear context →
2025-11-23-17-12-48-x9k2.png
Image Editing
When the user wants to modify an existing image:
- Check 如果 它们 provide image path 或 reference image 在...中 current directory
- 使用
--输入框-imageparameter 带有 path 到 image - prompt 应该 contain editing instructions (e.g., "使 sky 更多 dramatic", "移除 person", "更改 到 cartoon 样式")
- Common editing tasks: 添加/移除 elements, 更改 样式, adjust colors, blur background, etc.
Prompt Handling
对于 generation: Pass 用户's image description 作为- 到 --prompt. 仅 rework 如果 clearly insufficient.
对于 editing: Pass editing instructions 在...中 --prompt (e.g., "添加 rainbow 在...中 sky", "使 look 点赞 watercolor painting")
Preserve user's creative intent in both cases.
Prompt Templates (high hit-rate)
Use templates when the user is vague or when edits must be precise.
- Generation 模板:
- Editing 模板 (preserve everything 否则):
输出
- Saves PNG 到 current directory (或 specified path 如果 filename includes directory)
- Script outputs 满 path 到 generated image
- 做 不 读取 image back - 只是 inform 用户 的 saved path
Examples
Generate 新的 image:
uv run ~/.codex/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
编辑 existing image:
uv run ~/.codex/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