AI image generation and processing workflow. Generate images from prompts; supports text-to-image, image-to-image, batch generation, image-host management, long-image merging, and packaging images into PPT. The core feature is per-image confirmation to avoid wasting API quota.
核心理念: 分析风格 → 设计提示词 → 用户确认 → 生成图像,避免额度浪费
图像生成:
图像处理:
适用场景:
不适用场景:
分析风格 → 设计提示词 → 安装依赖 → 配置API → 确认生成 → 保存图像
↓ ↓ ↓ ↓ ↓ ↓
风格文件 提示词文件 node-fetch secrets.md 逐张确认 images/
所有脚本位于 ~/.claude/skills/pw-image-generation/scripts/ 目录中。
Agent 执行说明:
SKILL_DIR${SKILL_DIR}/scripts/<script-name>.ts${SKILL_DIR} 替换为实际路径可用脚本:
| 脚本 | 功能 | 参数 |
|------|------|------|
| generate-image.ts | 生成图像 (逐张确认) | [输出目录] |
| upload-image.ts | 上传图片到图床 | <图片路径> |
| delete-image.ts | 管理图床图片 | list\|delete <索引>\|delete-all |
| merge-to-long-image.ts | 合并为长图 | <图片目录> <输出文件> |
| merge-to-pptx.ts | 打包为 PPT | <图片目录> <输出文件> |
| analyze-image.ts | 分析图像风格 | <图像URL或路径> |
mkdir my-image-project && cd my-image-project
cp -r ~/.claude/skills/pw-image-generation/config.example ./config
cp ~/.claude/skills/pw-image-generation/references/.gitignore.template ./.gitignore
# 编辑 config/secrets.md 自定义 API 密钥(可选)
mkdir -p prompts
cp ~/.claude/skills/pw-image-generation/references/prompt-templates/提示词模板.md ./prompts/我的提示词.md
vim ./prompts/我的提示词.md
参考 references/style-library.md 选择合适的风格。
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
脚本会逐张询问确认,避免浪费额度。
命令:
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [输出目录]
参数说明:
[输出目录]: 可选,指定图像保存目录,默认为 ./images工作流程:
prompts/ 目录下的所有提示词文件确认选项:
y (yes): 生成当前图像n (no): 跳过当前图像,继续下一张q (quit): 退出生成流程示例:
# 使用默认输出目录
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 指定输出目录
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts ./my-images
命令:
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <图片路径>
参数说明:
<图片路径>: 必需,要上传的本地图片文件路径功能特性:
.upload-history.json示例:
# 上传单张图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# 上传后会返回:
# - 图片 URL (用于提示词中的 image_url)
# - 删除链接 (保存在历史记录中)
输出示例:
上传成功!
图片 URL: https://iili.io/xxx.png
删除链接已保存到 .upload-history.json
命令:
# 列出所有上传的图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts list
# 删除指定索引的图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete <索引>
# 删除所有图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all
参数说明:
list: 列出所有上传记录delete <索引>: 删除指定索引的图片 (索引从 0 开始)delete-all: 删除所有图片功能特性:
示例:
# 查看上传历史
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts list
# 输出:
# 0: 参考图.png - https://iili.io/xxx.png (2024-01-15)
# 1: 配图1.png - https://iili.io/yyy.png (2024-01-16)
# 删除索引为 0 的图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete 0
# 删除所有图片 (会要求确认)
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all
详细说明见 references/图床上传.md
命令:
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <图片目录> <输出文件>
参数说明:
<图片目录>: 必需,包含要合并的图片的目录<输出文件>: 必需,输出的长图文件名功能特性:
依赖要求: 需要安装 ImageMagick:
brew install imagemagick
示例:
# 合并 images 目录下的所有图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./images 长图.png
# 指定其他目录
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./my-images 合集.jpg
使用场景:
命令:
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <图片目录> <输出文件>
参数说明:
<图片目录>: 必需,包含要打包的图片的目录<输出文件>: 必需,输出的 PPT 文件名功能特性:
示例:
# 打包 images 目录下的图片为 PPT
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images 配图.pptx
# 指定其他目录
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./my-images 展示.pptx
使用场景:
命令:
# 从 URL 分析
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <图像URL>
# 从本地文件分析
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <本地路径>
参数说明:
<图像URL或路径>: 必需,要分析的图像 URL 或本地文件路径功能特性:
analysis/ 目录示例:
# 分析在线图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts https://example.com/image.jpg
# 分析本地图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts ./template/参考图.png
使用场景:
my-image-project/
├── config/
│ └── secrets.md # API 配置(可选)
├── template/ # PDF 模板图片
├── prompts/ # 提示词文件
├── analysis/ # 风格分析(可选)
├── images/ # 生成的图像
└── .gitignore
pw-image-generation/
├── SKILL.md # 本文件(核心文档)
├── config.example/ # 配置模板
│ ├── README.md # 配置说明
│ └── secrets.md # API 配置模板
├── references/ # 参考文档
│ ├── .gitignore.template # Git 忽略文件模板
│ ├── 图床上传.md # 图床上传指南
│ ├── style-library.md # 风格库(9种预设风格)
│ └── prompt-templates/
│ └── 提示词模板.md # 提示词模板
└── scripts/
├── analyze-image.ts # 分析图像风格
├── generate-image.ts # 生成图像(支持确认和跳过)
├── upload-image.ts # 上传图片到图床
├── delete-image.ts # 管理和删除图床图片
├── merge-to-long-image.ts # 合并长图
└── merge-to-pptx.ts # 打包为 PPT
问题: 图像生成失败或返回错误
可能原因:
解决方案:
# 检查配置文件
cat config/secrets.md
# 验证提示词格式
cat prompts/提示词.md
# 测试网络连接
curl -I https://api.openai.com
# 查看详细错误信息 (脚本会自动显示)
问题: 上传图片到图床失败
可能原因:
解决方案:
# 检查文件是否存在
ls -lh ./template/图片.png
# 检查文件大小
du -h ./template/图片.png
# 如果文件过大,压缩图片
# 使用 ImageMagick 压缩
convert ./template/图片.png -quality 85 -resize 2000x2000\> ./template/图片_compressed.png
问题: 合并长图时报错 "ImageMagick not found"
可能原因:
解决方案:
# macOS 安装
brew install imagemagick
# 验证安装
convert --version
# 如果仍然失败,检查 PATH
which convert
问题: 生成 PPT 时报错或 PPT 无法打开
可能原因:
解决方案:
# 检查图片目录
ls -la ./images
# 检查图片格式 (支持 jpg/png/gif/webp)
file ./images/*.png
# 确保输出目录存在
mkdir -p ./output
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images ./output/配图.pptx
问题: 生成的图像与提示词描述不符
可能原因:
解决方案:
# 不好的提示词
一张图片
# 好的提示词
水彩风格,温馨的咖啡馆场景,柔和的光线,暖色调,手绘质感
# 使用风格库
参考 references/style-library.md 选择合适的风格描述
问题: 批量生成过程中意外中断
可能原因:
解决方案:
n 选项跳过不需要的图像问题: 配置文件不生效或找不到
可能原因:
解决方案:
# 复制配置模板
cp -r ~/.claude/skills/pw-image-generation/config.example ./config
# 检查配置文件
cat config/secrets.md
# 配置文件格式示例
# API_BASE_URL=https://api.openai.com/v1
# API_KEY=sk-xxx
根据不同使用场景选择合适的图像尺寸:
| 场景 | 比例 | 推荐像素 | 说明 | |------|------|----------|------| | 文章配图 | 16:9 | 1920×1080 | 高清标准, 适配大屏阅读 | | 公众号封面 | 2.35:1 | 900×383 | 微信官方推荐尺寸 | | 小红书封面/配图 | 3:4 | 1242×1660 | 小红书推荐, 适配 iPhone 屏幕 | | X 文章封面 | 5:2 | 1500×600 | X Articles 官方推荐 | | 论文配图 | 16:9 | 1920×1080 | 高清标准 |
补充说明:
使用建议:
size: 1920x1080 或 aspect_ratio: 16:9基本原则:
推荐结构:
[风格] + [主体] + [场景] + [氛围] + [技术细节]
示例:
水彩风格,一只可爱的小猫,坐在窗台上,温暖的午后阳光,柔和的色彩,手绘质感
参考资源:
references/style-library.md: 9 种预设风格references/prompt-templates/提示词模板.md: 提示词模板推荐步骤:
避免浪费:
n 选项跳过不需要的图像q 选项及时退出上传参考图:
# 1. 上传参考图到图床
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# 2. 复制返回的 URL
# 3. 在提示词中使用
# image_url: https://iili.io/xxx.png
# prompt: 类似风格的场景,保持色调和构图
注意事项:
目录结构建议:
my-image-project/
├── config/ # 配置文件 (不提交到 git)
├── template/ # 参考图片
├── prompts/ # 提示词文件
│ ├── 01-封面.md
│ ├── 02-内容1.md
│ └── 03-内容2.md
├── images/ # 生成的图像
│ ├── 01-封面.png
│ ├── 02-内容1.png
│ └── 03-内容2.png
└── output/ # 最终输出 (长图/PPT)
命名规范:
提高生成速度:
节省 API 额度:
检查清单:
常见问题:
config/secrets.md 是可选的脚本使用 Bun 运行,无需本地安装依赖:
# 直接运行,Bun 会自动处理依赖
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
系统要求:
查看 config.example/secrets.md 了解配置选项:
可配置项:
API_BASE_URL: API 基础 URL (默认: OpenAI API)ANALYSIS_MODEL_ID: 图像分析模型 (默认: gpt-4-vision-preview)GENERATION_MODEL_ID: 图像生成模型 (默认: dall-e-3)API_KEY: API 密钥 (必需)配置示例:
# config/secrets.md
API_BASE_URL=https://api.openai.com/v1
ANALYSIS_MODEL_ID=gpt-4-vision-preview
GENERATION_MODEL_ID=dall-e-3
API_KEY=sk-your-api-key-here
Skill 提供 9 种预设风格,保证图像风格一致性:
查看 references/style-library.md 了解每种风格的详细说明和使用场景。
当用户请求生成图像时:
场景 1: 文章配图
# 1. 创建项目
mkdir article-images && cd article-images
# 2. 准备提示词
mkdir prompts
# 创建 prompts/01-封面.md, 02-配图1.md 等
# 3. 生成图像
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 4. 合并长图 (可选)
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./images 长图.png
场景 2: PPT 配图
# 1. 创建项目
mkdir ppt-images && cd ppt-images
# 2. 准备提示词 (按页面顺序命名)
mkdir prompts
# 创建 prompts/01-标题页.md, 02-内容1.md 等
# 3. 生成图像
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 4. 打包为 PPT
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images 配图.pptx
场景 3: 图生图
# 1. 上传参考图
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# 2. 在提示词中使用返回的 URL
# prompts/01-类似风格.md:
# image_url: https://iili.io/xxx.png
# prompt: 类似风格的场景,保持色调和构图
# 3. 生成图像
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 生成图像
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [输出目录]
# 上传图片
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <图片路径>
# 管理图床
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts list
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete <索引>
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all
# 合并长图
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <图片目录> <输出文件>
# 打包 PPT
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <图片目录> <输出文件>
# 分析图像
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <图像URL或路径>
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer