AgentSkillsCN

nano-banana

使用 Google 的 Gemini 3 Pro Image 模型(Nano Banana Pro),生成、编辑与创作图像。当用户提出“创作图像”、“生成视觉素材”、“编辑照片”、“合成多张图像”、“设计 Logo”、“制作缩略图”、“绘制信息图”、“拍摄产品样图”,或进行各类图像生成任务时,可使用此技能。它支持文本转图像、图像编辑、多图像合成(最多可容纳 14 张图像)、迭代优化、长宽比控制,以及基于 Google 搜索的图像生成,助力实时数据可视化。

SKILL.md
--- frontmatter
name: nano-banana
description: Generate, edit, and compose images using Google's Gemini 3 Pro Image model (Nano Banana Pro). Use this skill when the user asks to create images, generate visuals, edit photos, compose multiple images, create logos, thumbnails, infographics, product shots, or any image generation task. Supports text-to-image, image editing, multi-image composition (up to 14 images), iterative refinement, aspect ratio control, and Google Search-grounded image generation for real-time data visualization.

Nano Banana Pro

Image generation skill powered by Google's Gemini 3 Pro Image model. Enables text-to-image generation, image editing, multi-image composition, and real-time data visualization.

Requirements

  • GEMINI_API_KEY environment variable set
  • Python packages: google-genai, Pillow

Install dependencies:

bash
pip install -r requirements.txt

Quick Start

Generate an Image

bash
python scripts/generate_image.py "A cat wearing a wizard hat" cat.png

Edit an Existing Image

bash
python scripts/edit_image.py photo.png "Add a sunset to the background" edited.png

Compose Multiple Images

bash
python scripts/compose_images.py "Create a group photo in an office" team.png person1.png person2.png

Available Scripts

ScriptPurpose
generate_image.pyText-to-image generation
edit_image.pyEdit/modify existing images
compose_images.pyCombine up to 14 reference images
chat_image.pyInteractive multi-turn refinement
search_grounded_image.pyGenerate images with real-time search data

Generation Options

Aspect Ratios

1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9

Resolutions

1K (1024px), 2K, 4K

Usage with Options

bash
python scripts/generate_image.py "Futuristic motorcycle on Mars" mars.png --aspect 16:9 --size 4K

Task Workflows

Logo Generation

bash
python scripts/generate_image.py "Clean black-and-white logo with text 'Daily Grind', sans-serif font, coffee bean icon, minimalist style" logo.png --aspect 1:1

Product Mockup

bash
python scripts/generate_image.py "Studio-lit product photo on polished concrete, 3-point softbox, 45-degree angle, professional e-commerce style" product.png --aspect 4:3 --size 4K

Photorealistic Portrait

bash
python scripts/generate_image.py "A photorealistic close-up portrait, shot on 85mm lens, golden hour lighting, shallow depth of field, cinematic" portrait.png --size 4K

Stylized Art (Anime/Sticker)

bash
python scripts/generate_image.py "A kawaii red panda sticker, bold outlines, cel-shading, white background, cute expression" sticker.png

Iterative Design Refinement

Use the chat script for back-and-forth refinement:

bash
python scripts/chat_image.py

Then interact:

code
> Create a logo for 'Acme Corp'
[Image generated]
> Make the text bolder and add a blue gradient
[Refined image]
> save acme_logo.png

Real-Time Data Visualization

Generate infographics with current data:

bash
python scripts/search_grounded_image.py "Visualize today's weather in Tokyo as an infographic" tokyo_weather.png --aspect 9:16

Use cases:

  • Live stock-market infographics
  • Breaking-news visuals
  • Weather dashboards
  • Current event visualizations

Multi-Image Composition

Combine reference images:

bash
python scripts/compose_images.py "Create a product comparison shot with these items side by side, professional lighting" comparison.png item1.png item2.png item3.png --aspect 16:9

Use cases:

  • Product comparison shots
  • Character sheets
  • Team photos
  • Style-consistent image series

Inline Python Usage

For integration in larger scripts:

python
import os
from google import genai
from google.genai import types

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents=["A serene mountain landscape at dawn"],
    config=types.GenerateContentConfig(
        response_modalities=['TEXT', 'IMAGE'],
        image_config=types.ImageConfig(
            aspect_ratio="16:9",
            image_size="2K"
        )
    )
)

for part in response.parts:
    if part.inline_data:
        image = part.as_image()
        image.save("landscape.png")

Editing with Inline Code

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

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
img = Image.open("input.png")

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents=["Add dramatic clouds to the sky", img],
    config=types.GenerateContentConfig(
        response_modalities=['TEXT', 'IMAGE']
    )
)

Prompting Tips

Photorealistic: Include camera settings, lighting, lens details

code
"Shot on 85mm lens, golden hour lighting, shallow depth of field"

Logos: Specify style, colors, typography

code
"Clean minimalist logo, sans-serif font, monochrome, vector style"

Product shots: Describe studio setup

code
"Studio-lit, 3-point softbox, polished surface, 45-degree angle"

Stylized art: Name the style explicitly

code
"Anime style, cel-shading, bold outlines, vibrant colors"