nano-image-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nano Image Generator

Nano图片生成工具

Generate images using Nano Banana Pro (Gemini 3 Pro Preview) for any visual asset needs.
使用Nano Banana Pro(Gemini 3 Pro预览版)满足各类视觉资产生成需求。

Requirements

配置要求

在项目根目录
.env
中配置:
  • apikey
    (或
    APIKEY
  • baseurl
    (或
    BASEURL
    ,例如
    https://generativelanguage.googleapis.com/v1beta/models
兼容回退:若未找到
apikey/APIKEY
,脚本会尝试
GEMINI_API_KEY
在项目根目录
.env
中配置:
  • apikey
    (或
    APIKEY
  • baseurl
    (或
    BASEURL
    ,例如
    https://generativelanguage.googleapis.com/v1beta/models
兼容回退:若未找到
apikey/APIKEY
,脚本会尝试
GEMINI_API_KEY

Quick Start

快速开始

bash
python scripts/generate_image.py "A friendly robot mascot waving" --output ./assets/mascot.png
bash
python scripts/generate_image.py "A friendly robot mascot waving" --output ./assets/mascot.png

Script Usage

脚本使用方法

bash
python scripts/generate_image.py <prompt> --output <path> [options]
Required:
  • prompt
    - Image description
  • --output, -o
    - Output file path
Options:
  • --aspect, -a
    - Aspect ratio (default:
    1:1
    )
    • Square:
      1:1
    • Portrait:
      2:3
      ,
      3:4
      ,
      4:5
      ,
      9:16
    • Landscape:
      3:2
      ,
      4:3
      ,
      5:4
      ,
      16:9
      ,
      21:9
  • --size, -s
    - Resolution:
    1K
    ,
    2K
    (default),
    4K
bash
python scripts/generate_image.py <prompt> --output <path> [options]
必填参数:
  • prompt
    - 图片描述
  • --output, -o
    - 输出文件路径
可选参数:
  • --aspect, -a
    - 宽高比(默认值:
    1:1
    • 正方形:
      1:1
    • 竖版:
      2:3
      ,
      3:4
      ,
      4:5
      ,
      9:16
    • 横版:
      3:2
      ,
      4:3
      ,
      5:4
      ,
      16:9
      ,
      21:9
  • --size, -s
    - 分辨率:
    1K
    2K
    (默认)、
    4K

Workflow

工作流程

  1. Determine output location - Place images where contextually appropriate:
    • App icons →
      ./assets/icons/
      or
      ./public/icons/
    • Marketing →
      ./marketing/
      or
      ./assets/images/
    • UI elements →
      ./src/assets/
      or
      ./public/images/
    • General →
      ./generated/
  2. Craft effective prompts - Be specific and descriptive:
    • Include style: "flat design", "3D rendered", "watercolor", "minimalist"
    • Include context: "for a mobile app", "website hero image", "social media post"
    • Include details: colors, mood, composition
  3. Choose appropriate settings:
    • Icons/logos →
      --aspect 1:1
    • Banners/headers →
      --aspect 16:9
    • Mobile screens →
      --aspect 9:16
    • Photos →
      --aspect 3:2
      or
      4:3
  1. 确定输出位置 - 根据使用场景选择合适的存放路径:
    • 应用图标 →
      ./assets/icons/
      ./public/icons/
    • 营销素材 →
      ./marketing/
      ./assets/images/
    • UI元素 →
      ./src/assets/
      ./public/images/
    • 通用素材 →
      ./generated/
  2. 撰写高效提示词 - 内容需具体且描述清晰:
    • 包含风格:"flat design"(扁平化设计)、"3D rendered"(3D渲染)、"watercolor"(水彩风格)、"minimalist"(极简风格)
    • 包含使用场景:"for a mobile app"(用于移动应用)、"website hero image"(网站首屏图)、"social media post"(社交媒体帖子)
    • 包含细节:颜色、氛围、构图
  3. 选择合适的参数设置:
    • 图标/Logo →
      --aspect 1:1
    • 横幅/页眉 →
      --aspect 16:9
    • 移动端屏幕 →
      --aspect 9:16
    • 照片类 →
      --aspect 3:2
      4:3

Examples

使用示例

App icon:
bash
python scripts/generate_image.py "Minimalist flat design app icon of a lightning bolt, purple gradient background, modern iOS style" \
  --output ./assets/app-icon.png --aspect 1:1
Marketing banner:
bash
python scripts/generate_image.py "Professional website hero banner for a productivity app, abstract geometric shapes, blue and white color scheme, modern and clean" \
  --output ./public/images/hero-banner.png --aspect 16:9
High-quality illustration:
bash
python scripts/generate_image.py "Detailed isometric illustration of a cozy home office setup with plants, warm lighting, digital art style" \
  --output ./assets/illustrations/office.png --size 4K
应用图标:
bash
python scripts/generate_image.py "Minimalist flat design app icon of a lightning bolt, purple gradient background, modern iOS style" \
  --output ./assets/app-icon.png --aspect 1:1
营销横幅:
bash
python scripts/generate_image.py "Professional website hero banner for a productivity app, abstract geometric shapes, blue and white color scheme, modern and clean" \
  --output ./public/images/hero-banner.png --aspect 16:9
高质量插画:
bash
python scripts/generate_image.py "Detailed isometric illustration of a cozy home office setup with plants, warm lighting, digital art style" \
  --output ./assets/illustrations/office.png --size 4K

Prompt Tips

提示词撰写技巧

  • Be specific - "A red apple on a wooden table" vs "an apple"
  • Include style - "in the style of pixel art" or "photorealistic"
  • Mention purpose - "for a children's book" affects the output style
  • Describe composition - "centered", "rule of thirds", "close-up"
  • Specify colors - Explicit color palettes yield better results
  • Avoid - Don't ask for text in images (use overlays instead)
  • 内容具体 - 对比“木桌上的红苹果”和“一个苹果”
  • 明确风格 - 例如“像素艺术风格”或“照片级写实”
  • 说明用途 - 标注“用于儿童书籍”会影响输出风格
  • 描述构图 - 如“居中布局”“三分法构图”“特写”
  • 指定颜色 - 明确的配色方案能获得更理想的结果
  • 注意避坑 - 不要要求在图片中生成文字(建议使用叠加层添加)