nano-banana-build

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nano Banana Image Generation Skill

Nano Banana图像生成Skill

Use this skill to generate and edit images using the
google-genai
Python SDK with Gemini's specialized image models (Nano Banana).
使用此Skill,通过
google-genai
Python SDK结合Gemini的专用图像模型(Nano Banana)来生成和编辑图像。

Quick Start Setup

快速开始设置

python
from google import genai
from google.genai import types
from PIL import Image
import io

client = genai.Client()
python
from google import genai
from google.genai import types
from PIL import Image
import io

client = genai.Client()

Reference Materials

参考资料

  • Model Capabilities: Comparison of Gemini 2.5 vs 3 Pro, resolutions, and token costs.
  • Image Generation: Text-to-Image, Interleaved Text/Image.
  • Image Editing: Subject Customization, Style Transfer, Multi-turn Editing.
  • Thinking Process: Understanding thoughts and signatures (Gemini 3 Pro).
  • Recipes: Extensive collection of examples (Logos, Stickers, Mockups, Comics, etc.).
  • Source Code: Deep inspection of SDK internals.
  • 模型能力: Gemini 2.5与3 Pro的对比、分辨率及令牌成本说明。
  • 图像生成: 文本生成图像、文本/图像交错生成。
  • 图像编辑: 主体定制、风格迁移、多轮编辑。
  • 思考过程: 理解Gemini 3 Pro的思考逻辑和签名机制。
  • 示例配方: 丰富的示例集合(标志、贴纸、模型图、漫画等)。
  • 源代码: 深入解析SDK内部实现。

Available Models

可用模型

  • gemini-2.5-flash-image
    (Nano Banana)
    : Fast, high-quality generation and editing. Best for most use cases.
  • gemini-3-pro-image-preview
    (Nano Banana Pro)
    : Highest fidelity, supports
    2K
    and
    4K
    resolution, complex prompt adherence, and grounding.
  • gemini-2.5-flash-image
    (Nano Banana)
    : 快速、高质量的生成与编辑。适用于大多数使用场景。
  • gemini-3-pro-image-preview
    (Nano Banana Pro)
    : 最高保真度,支持
    2K
    4K
    分辨率,精准贴合复杂提示词,具备图像grounding能力。

Common Workflows

常见工作流

1. Fast Generation

1. 快速生成

python
response = client.models.generate_content(
    model='gemini-2.5-flash-image',
    contents='A cute robot eating a banana',
    config=types.GenerateContentConfig(
        response_modalities=['IMAGE']
    )
)
python
response = client.models.generate_content(
    model='gemini-2.5-flash-image',
    contents='A cute robot eating a banana',
    config=types.GenerateContentConfig(
        response_modalities=['IMAGE']
    )
)

2. High-Quality Editing

2. 高质量编辑

python
response = client.models.generate_content(
    model='gemini-3-pro-image-preview',
    contents=[
        types.Part.from_uri(file_uri='gs://.../shoe.jpg', mime_type='image/jpeg'),
        "Change the color of the shoe to neon green."
    ],
    config=types.GenerateContentConfig(response_modalities=['IMAGE'])
)
python
response = client.models.generate_content(
    model='gemini-3-pro-image-preview',
    contents=[
        types.Part.from_uri(file_uri='gs://.../shoe.jpg', mime_type='image/jpeg'),
        "Change the color of the shoe to neon green."
    ],
    config=types.GenerateContentConfig(response_modalities=['IMAGE'])
)