关于 imagen
Imagen 是 Claude Code 技能,使用 Google Gemini 根据文本提示生成 PNG 图像,适用于需要自定义视觉素材的开发和文档任务,并可将结果保存到指定路径。
主要功能
- 01根据文本提示生成图像
- 02自定义输出路径
- 03调整图像尺寸
- 04输出 PNG 文件
- 05支持 Windows、macOS 和 Linux
适用场景
- 01制作前端图像和占位图
- 02为文档添加插图
- 03呈现概念或架构
- 04生成图标、Logo 或 UI 素材
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ sanjay3290/ ai-skills --skill imagen安装后在 Claude Code 中输入/imagen确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.env.example.gitignoreexamples.mdREADME.mdreference.mdscripts/generate_image.py详细介绍
Imagen - AI 图像生成工具
概述
此工具使用 Google Gemini 的图像生成模型(gemini-3-pro-image-preview)生成图像。它可在任何 Claude Code 会话中无缝创建图像,无论是构建前端 UI、编写文档,还是需要概念的可视化呈现。
跨平台:支持 Windows、macOS 和 Linux。
何时使用此工具
在以下情况下自动启用此工具:
- 用户请求生成图像(例如:“生成一张……的图像”“创建一张图片……”)
- 前端开发需要占位图或实际图像
- 文档需要插图或图表
- 将概念、架构或想法可视化
- 创建图标、徽标或 UI 资源
- 任何适合使用 AI 生成图像的任务
工作原理
- 接收描述目标图像的文本提示词
- 使用图像生成配置调用 Google Gemini API
- 将生成的图像保存到指定位置(默认为当前目录)
- 返回文件路径,以便在项目中使用
用法
Python(跨平台 - 推荐)
# Basic usage
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"
# With custom size
python scripts/generate_image.py --size 2K "High resolution landscape" "./wallpaper.png"
要求
- 必须设置
GEMINI_API_KEY环境变量 - Python 3.6+(仅使用标准库,无需安装 pip 包)
输出
生成的图像将保存为 PNG 文件。脚本返回:
- 成功:生成图像的路径
- 失败:包含详细信息的错误消息
示例
前端开发
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: "Create a diagram showing microservices architecture"
-> Generates visual representation, ready for README or docs
UI 资源
User: "Generate a placeholder avatar image for the user profile component"
-> Creates image in appropriate size for component use
评论
支持 Markdown