imagen

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Imagen - AI Image Generation Skill

Imagen - AI图像生成技能

Overview

概述

This skill generates images using Google Gemini's image generation model (
gemini-3-pro-image-preview
). It enables seamless image creation during any Claude Code session - whether you're building frontend UIs, creating documentation, or need visual representations of concepts.
Cross-Platform: Works on Windows, macOS, and Linux.
本技能使用Google Gemini的图像生成模型(
gemini-3-pro-image-preview
)生成图片。它能在任何Claude Code会话中无缝创建图片——无论你是构建前端UI、创建文档,还是需要将概念视觉化呈现。
跨平台兼容:支持Windows、macOS和Linux系统。

When to Use This Skill

适用场景

Automatically activate this skill when:
  • User requests image generation (e.g., "generate an image of...", "create a picture...")
  • Frontend development requires placeholder or actual images
  • Documentation needs illustrations or diagrams
  • Visualizing concepts, architectures, or ideas
  • Creating icons, logos, or UI assets
  • Any task where an AI-generated image would be helpful
在以下场景自动激活此技能:
  • 用户请求生成图片(例如:“生成一张……的图片”、“创建一幅图画……”)
  • 前端开发需要占位图或实际图片
  • 文档需要插图或图表
  • 将概念、架构或想法可视化
  • 创建图标、标志或UI资源
  • 任何AI生成图片能起到帮助作用的任务

How It Works

工作原理

  1. Takes a text prompt describing the desired image
  2. Calls Google Gemini API with image generation configuration
  3. Saves the generated image to a specified location (defaults to current directory)
  4. Returns the file path for use in your project
  1. 接收描述所需图片的文本提示词
  2. 使用图像生成配置调用Google Gemini API
  3. 将生成的图片保存到指定位置(默认保存至当前目录)
  4. 返回文件路径,以便在项目中使用

Usage

使用方法

Python (Cross-Platform - Recommended)

Python(跨平台 - 推荐)

bash
undefined
bash
undefined

Basic usage

基础用法

python scripts/generate_image.py "A futuristic city skyline at sunset"
python scripts/generate_image.py "A futuristic city skyline at sunset"

With custom output path

自定义输出路径

python scripts/generate_image.py "A minimalist app icon for a music player" "./assets/icons/music-icon.png"
python scripts/generate_image.py "A minimalist app icon for a music player" "./assets/icons/music-icon.png"

With custom size

自定义尺寸

python scripts/generate_image.py --size 2K "High resolution landscape" "./wallpaper.png"
undefined
python scripts/generate_image.py --size 2K "High resolution landscape" "./wallpaper.png"
undefined

Requirements

必要条件

  • GEMINI_API_KEY
    environment variable must be set
  • Python 3.6+ (uses standard library only, no pip install needed)
  • 必须设置
    GEMINI_API_KEY
    环境变量
  • Python 3.6+(仅使用标准库,无需通过pip安装依赖)

Output

输出结果

Generated images are saved as PNG files. The script returns:
  • Success: Path to the generated image
  • Failure: Error message with details
生成的图片将保存为PNG格式文件。脚本返回:
  • 成功:生成的图片路径
  • 失败:包含详细信息的错误提示

Examples

示例

Frontend Development

前端开发

User: "I need a hero image for my landing page - something abstract and tech-focused"
-> Generates and saves image, provides path for use in HTML/CSS
User: "I need a hero image for my landing page - something abstract and tech-focused"
-> Generates and saves image, provides path for use in HTML/CSS

Documentation

文档编写

User: "Create a diagram showing microservices architecture"
-> Generates visual representation, ready for README or docs
User: "Create a diagram showing microservices architecture"
-> Generates visual representation, ready for README or docs

UI Assets

UI资源

User: "Generate a placeholder avatar image for the user profile component"
-> Creates image in appropriate size for component use
User: "Generate a placeholder avatar image for the user profile component"
-> Creates image in appropriate size for component use