Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/nanobanana
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# dependencies = ["google-genai", "Pillow"]
# ///
"""
nanobanana - Image editing with Gemini's Nano Banana Pro API
nanobanana - Image editing with Gemini's Nano Banana 2 API
Usage: nanobanana <image-path> "<prompt>" [output-path]

Examples:
Expand Down Expand Up @@ -46,12 +46,12 @@ def edit_image(image_path: str, prompt: str, output_path: str | None = None) ->
base, ext = os.path.splitext(image_path)
output_path = f"{base}_edited{ext}"

print(f"🍌 Sending to Nano Banana Pro...")
print(f"🍌 Sending to Nano Banana 2...")
print(f" Prompt: {prompt}")

try:
response = client.models.generate_content(
model="gemini-2.5-flash-image",
model="gemini-3.1-flash-image-preview",
contents=[prompt, image],
config=genai.types.GenerateContentConfig(response_modalities=["TEXT", "IMAGE"]),
)
Expand Down
14 changes: 8 additions & 6 deletions skills/nano-banana-pro/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
name: nano-banana-pro
description: Generate/edit images with Nano Banana Pro (Gemini 3 Pro Image). Use for image create/modify requests incl. edits. Supports text-to-image + image-to-image; 1K/2K/4K; use --input-image.
description: Generate/edit images with Nano Banana 2 (Gemini 3.1 Flash Image Preview). Use for image create/modify requests incl. edits. Supports text-to-image + image-to-image; 0.5K/1K/2K/4K; use --input-image.
---

# Nano Banana Pro Image Generation & Editing
# Nano Banana 2 Image Generation & Editing

Generate new images or edit existing ones using Google's Nano Banana Pro API (Gemini 3 Pro Image).
Generate new images or edit existing ones using Google's Nano Banana 2 API (Gemini 3.1 Flash Image Preview).

## Usage

Run the script using absolute path (do NOT cd to skill directory first):

**Generate new image:**
```bash
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]
uv run ~/.codex/skills/nano-banana-pro/scripts/generate_image.py --prompt "your image description" --filename "output-name.png" [--resolution 0.5K|1K|2K|4K] [--api-key KEY]
```

**Edit existing image:**
```bash
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]
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 0.5K|1K|2K|4K] [--api-key KEY]
```

**Important:** Always run from the user's current working directory so images are saved where the user is working, not in the skill directory.
Expand All @@ -36,13 +36,15 @@ Goal: fast iteration without burning time on 4K until the prompt is correct.

## Resolution Options

The Gemini 3 Pro Image API supports three resolutions (uppercase K required):
The Gemini 3.1 Flash Image Preview API supports these resolutions (uppercase K required):

- **0.5K** - ~512px resolution
- **1K** (default) - ~1024px resolution
- **2K** - ~2048px resolution
- **4K** - ~4096px resolution

Map user requests to API parameters:
- "512", "512px", "0.5K", "thumbnail", "tiny" → `0.5K`
- No mention of resolution → `1K`
- "low resolution", "1080", "1080p", "1K" → `1K`
- "2K", "2048", "normal", "medium resolution" → `2K`
Expand Down
12 changes: 6 additions & 6 deletions skills/nano-banana-pro/scripts/generate_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
# ]
# ///
"""
Generate images using Google's Nano Banana Pro (Gemini 3 Pro Image) API.
Generate images using Google's Nano Banana 2 (Gemini 3.1 Flash Image Preview) API.

Usage:
uv run generate_image.py --prompt "your image description" --filename "output.png" [--resolution 1K|2K|4K] [--api-key KEY]
uv run generate_image.py --prompt "your image description" --filename "output.png" [--resolution 0.5K|1K|2K|4K] [--api-key KEY]
"""

import argparse
Expand All @@ -28,7 +28,7 @@ def get_api_key(provided_key: str | None) -> str | None:

def main():
parser = argparse.ArgumentParser(
description="Generate images using Nano Banana Pro (Gemini 3 Pro Image)"
description="Generate images using Nano Banana 2 (Gemini 3.1 Flash Image Preview)"
)
parser.add_argument(
"--prompt", "-p",
Expand All @@ -46,9 +46,9 @@ def main():
)
parser.add_argument(
"--resolution", "-r",
choices=["1K", "2K", "4K"],
choices=["0.5K", "1K", "2K", "4K"],
default="1K",
help="Output resolution: 1K (default), 2K, or 4K"
help="Output resolution: 0.5K, 1K (default), 2K, or 4K"
)
parser.add_argument(
"--api-key", "-k",
Expand Down Expand Up @@ -112,7 +112,7 @@ def main():

try:
response = client.models.generate_content(
model="gemini-3-pro-image-preview",
model="gemini-3.1-flash-image-preview",
contents=contents,
config=types.GenerateContentConfig(
response_modalities=["TEXT", "IMAGE"],
Expand Down