pw-image-generation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Image-Generation - AI 图像生成工作流

Image-Generation - AI Image Generation Workflow

核心理念: 分析风格 → 设计提示词 → 用户确认 → 生成图像,避免额度浪费
Core Concept: Analyze Style → Design Prompts → User Confirmation → Generate Images, Avoid Credit Wastage

核心功能

Core Features

图像生成:
  • 文生图: 根据文本描述生成图像
  • 图生图: 基于参考图片生成类似风格的图像
  • 批量生成: 使用提示词模板批量生成多张图像
  • 风格一致: 保持系列图像的视觉风格统一
图像处理:
  • 长图合并: 将系列图片垂直拼接为一张长图
  • PPT 打包: 将系列图片打包为 PPT 文件 (每张图片一页)
  • 图床管理: 上传图片到图床并管理删除链接
Image Generation:
  • Text-to-Image: Generate images based on text descriptions
  • Image-to-Image: Generate images with similar styles based on reference images
  • Batch Generation: Generate multiple images in batches using prompt templates
  • Consistent Style: Maintain unified visual style for a series of images
Image Processing:
  • Long Image Merging: Vertically stitch a series of images into a single long image
  • PPT Packaging: Package a series of images into a PPT file (one image per page)
  • Image Hosting Management: Upload images to hosting services and manage deletion links

使用时机

Usage Scenarios

适用场景:
  • 用户明确要求 "生成图像"、"创建配图"、"制作插画"
  • 用户提供文本描述并需要视觉化呈现
  • 用户提供参考图片并要求生成类似风格的图像
  • 用户需要为文章、PPT、社交媒体制作配图
  • 用户需要批量生成风格一致的系列图像
  • 用户需要将多张图片合并为长图或 PPT
不适用场景:
  • 用户只是询问如何生成图像 (提供建议即可)
  • 用户需要编辑现有图片 (使用图片编辑工具)
  • 用户需要图像识别或分析 (使用视觉分析工具)
  • 用户需要截图或屏幕录制 (使用系统工具)

Applicable Scenarios:
  • Users explicitly request "generate images", "create illustrations", "make artwork"
  • Users provide text descriptions and need visual representation
  • Users provide reference images and request images with similar styles
  • Users need to create illustrations for articles, PPTs, or social media
  • Users need to batch generate a series of images with consistent style
  • Users need to merge multiple images into a long image or PPT
Inapplicable Scenarios:
  • Users only ask how to generate images (provide advice only)
  • Users need to edit existing images (use image editing tools)
  • Users need image recognition or analysis (use visual analysis tools)
  • Users need screenshots or screen recording (use system tools)

工作流程

Workflow

分析风格 → 设计提示词 → 安装依赖 → 配置API → 确认生成 → 保存图像
    ↓          ↓           ↓         ↓         ↓         ↓
  风格文件    提示词文件   node-fetch  secrets.md  逐张确认  images/

Analyze Style → Design Prompts → Install Dependencies → Configure API → Confirm Generation → Save Images
    ↓          ↓           ↓         ↓         ↓         ↓
  Style Files  Prompt Files   node-fetch  secrets.md  One-by-One Confirmation  images/

脚本目录

Script Directory

所有脚本位于
~/.claude/skills/pw-image-generation/scripts/
目录中。
Agent 执行说明:
  1. 确定此 SKILL.md 文件的目录路径为
    SKILL_DIR
  2. 脚本路径 =
    ${SKILL_DIR}/scripts/<script-name>.ts
  3. 将本文档中的所有
    ${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或路径>
All scripts are located in the
~/.claude/skills/pw-image-generation/scripts/
directory.
Agent Execution Instructions:
  1. Determine the directory path of this SKILL.md file as
    SKILL_DIR
  2. Script path =
    ${SKILL_DIR}/scripts/<script-name>.ts
  3. Replace all
    ${SKILL_DIR}
    in this document with the actual path
Available Scripts:
ScriptFunctionParameters
generate-image.ts
Generate images (with one-by-one confirmation)
[output directory]
upload-image.ts
Upload images to hosting service
<image path>
delete-image.ts
Manage hosted images
list|delete <index>|delete-all
merge-to-long-image.ts
Merge into long image
<image directory> <output file>
merge-to-pptx.ts
Package into PPT
<image directory> <output file>
analyze-image.ts
Analyze image style
<image URL or path>

快速开始

Quick Start

Step 1: 创建项目目录

Step 1: Create Project Directory

bash
mkdir my-image-project && cd my-image-project
bash
mkdir my-image-project && cd my-image-project

Step 2: 复制配置模板(可选)

Step 2: Copy Configuration Template (Optional)

bash
cp -r ~/.claude/skills/pw-image-generation/config.example ./config
cp ~/.claude/skills/pw-image-generation/references/.gitignore.template ./.gitignore
bash
cp -r ~/.claude/skills/pw-image-generation/config.example ./config
cp ~/.claude/skills/pw-image-generation/references/.gitignore.template ./.gitignore

编辑 config/secrets.md 自定义 API 密钥(可选)

Edit config/secrets.md to customize API keys (optional)

undefined
undefined

Step 3: 创建提示词

Step 3: Create Prompts

bash
mkdir -p prompts
cp ~/.claude/skills/pw-image-generation/references/prompt-templates/提示词模板.md ./prompts/我的提示词.md
vim ./prompts/我的提示词.md
参考
references/style-library.md
选择合适的风格。
bash
mkdir -p prompts
cp ~/.claude/skills/pw-image-generation/references/prompt-templates/提示词模板.md ./prompts/我的提示词.md
vim ./prompts/我的提示词.md
Refer to
references/style-library.md
to select appropriate styles.

Step 4: 生成图像

Step 4: Generate Images

bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
脚本会逐张询问确认,避免浪费额度。

bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
The script will ask for confirmation for each image to avoid credit waste.

工具脚本详解

Tool Script Details

1. 生成图像

1. Generate Images

命令:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [输出目录]
参数说明:
  • [输出目录]
    : 可选,指定图像保存目录,默认为
    ./images
工作流程:
  1. 读取
    prompts/
    目录下的所有提示词文件
  2. 逐张显示提示词内容
  3. 询问是否生成该图像 (y/n/q)
  4. 生成图像并保存到输出目录
  5. 支持中断和恢复
确认选项:
  • y
    (yes): 生成当前图像
  • n
    (no): 跳过当前图像,继续下一张
  • q
    (quit): 退出生成流程
示例:
bash
undefined
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [output directory]
Parameter Explanation:
  • [output directory]
    : Optional, specify the image save directory, default is
    ./images
Workflow:
  1. Read all prompt files in the
    prompts/
    directory
  2. Display each prompt content one by one
  3. Ask whether to generate the image (y/n/q)
  4. Generate and save the image to the output directory
  5. Support interruption and resumption
Confirmation Options:
  • y
    (yes): Generate current image
  • n
    (no): Skip current image and continue to the next
  • q
    (quit): Exit the generation process
Examples:
bash
undefined

使用默认输出目录

Use default output directory

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

指定输出目录

Specify output directory

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts ./my-images

---
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts ./my-images

---

2. 上传图片到图床

2. Upload Images to Hosting Service

命令:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <图片路径>
参数说明:
  • <图片路径>
    : 必需,要上传的本地图片文件路径
功能特性:
  • 自动上传到 freeimage.host (永久存储)
  • 返回可用的图片 URL
  • 自动保存删除链接到
    .upload-history.json
  • 用于图生图的参考图上传
示例:
bash
undefined
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <image path>
Parameter Explanation:
  • <image path>
    : Required, path to the local image file to upload
Features:
  • Automatically upload to freeimage.host (permanent storage)
  • Return usable image URL
  • Automatically save deletion link to
    .upload-history.json
  • Used for reference image upload in image-to-image generation
Example:
bash
undefined

上传单张图片

Upload single image

npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png

上传后会返回:

After upload, you will get:

- 图片 URL (用于提示词中的 image_url)

- Image URL (used for image_url in prompts)

- 删除链接 (保存在历史记录中)

- Deletion link (saved in history)


**输出示例**:
上传成功! 图片 URL: https://iili.io/xxx.png 删除链接已保存到 .upload-history.json

---

**Output Example**:
Upload successful! Image URL: https://iili.io/xxx.png Deletion link saved to .upload-history.json

---

3. 管理图床图片

3. Manage Hosted Images

命令:
bash
undefined
Command:
bash
undefined

列出所有上传的图片

List all uploaded images

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 list

删除指定索引的图片

Delete image with specified index

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 <index>

删除所有图片

Delete all images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all

**参数说明**:
- `list`: 列出所有上传记录
- `delete <索引>`: 删除指定索引的图片 (索引从 0 开始)
- `delete-all`: 删除所有图片

**功能特性**:
- 查看上传历史和删除链接
- 单个或批量删除图片
- 自动更新历史记录文件

**示例**:
```bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all

**Parameter Explanation**:
- `list`: List all upload records
- `delete <index>`: Delete image with specified index (index starts from 0)
- `delete-all`: Delete all images

**Features**:
- View upload history and deletion links
- Delete single or batch images
- Automatically update history file

**Example**:
```bash

查看上传历史

View upload history

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 list

输出:

Output:

0: 参考图.png - https://iili.io/xxx.png (2024-01-15)

0: 参考图.png - https://iili.io/xxx.png (2024-01-15)

1: 配图1.png - https://iili.io/yyy.png (2024-01-16)

1: 配图1.png - https://iili.io/yyy.png (2024-01-16)

删除索引为 0 的图片

Delete image with index 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 0

删除所有图片 (会要求确认)

Delete all images (requires confirmation)

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/delete-image.ts delete-all

For detailed instructions, see `references/图床上传.md`

---

4. 合并长图

4. Merge into Long Image

命令:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <图片目录> <输出文件>
参数说明:
  • <图片目录>
    : 必需,包含要合并的图片的目录
  • <输出文件>
    : 必需,输出的长图文件名
功能特性:
  • 垂直拼接多张图片
  • 自动识别 jpg/png/gif/webp 格式
  • 按文件名数字排序
  • 保持原图宽度,自动计算高度
依赖要求: 需要安装 ImageMagick:
bash
brew install imagemagick
示例:
bash
undefined
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <image directory> <output file>
Parameter Explanation:
  • <image directory>
    : Required, directory containing images to merge
  • <output file>
    : Required, filename of the output long image
Features:
  • Vertically stitch multiple images
  • Automatically recognize jpg/png/gif/webp formats
  • Sort by filename numbers
  • Maintain original image width, automatically calculate height
Dependency Requirement: Need to install ImageMagick:
bash
brew install imagemagick
Example:
bash
undefined

合并 images 目录下的所有图片

Merge all images in images directory

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 ./images 长图.png

指定其他目录

Specify other directory

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-long-image.ts ./my-images 合集.jpg

**Usage Scenarios**:
- Create long images for Xiaohongshu/WeChat Official Accounts
- Merge series tutorial screenshots
- Create image collection displays

---

5. 合并为 PPT

5. Package into PPT

命令:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <图片目录> <输出文件>
参数说明:
  • <图片目录>
    : 必需,包含要打包的图片的目录
  • <输出文件>
    : 必需,输出的 PPT 文件名
功能特性:
  • 每张图片占一页
  • 自动识别 jpg/png/gif/webp 格式
  • 按文件名数字排序
  • 16:9 比例,自动适应页面大小
  • 图片居中显示
示例:
bash
undefined
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <image directory> <output file>
Parameter Explanation:
  • <image directory>
    : Required, directory containing images to package
  • <output file>
    : Required, filename of the output PPT
Features:
  • One image per page
  • Automatically recognize jpg/png/gif/webp formats
  • Sort by filename numbers
  • 16:9 aspect ratio, automatically adapt to page size
  • Images displayed in center
Example:
bash
undefined

打包 images 目录下的图片为 PPT

Package images in images directory into 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 ./images 配图.pptx

指定其他目录

Specify other directory

npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./my-images 展示.pptx

**使用场景**:
- 快速制作图片演示 PPT
- 打包系列配图用于分享
- 将生成的图像整理成演示文档

---
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./my-images 展示.pptx

**Usage Scenarios**:
- Quickly create image demonstration PPTs
- Package series illustrations for sharing
- Organize generated images into presentation documents

---

6. 分析图像风格

6. Analyze Image Style

命令:
bash
undefined
Command:
bash
undefined

从 URL 分析

Analyze from 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 <image URL>

从本地文件分析

Analyze from local file

npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <本地路径>

**参数说明**:
- `<图像URL或路径>`: 必需,要分析的图像 URL 或本地文件路径

**功能特性**:
- 分析图像的视觉风格
- 生成适合的提示词建议
- 识别颜色、构图、艺术风格
- 保存分析结果到 `analysis/` 目录

**示例**:
```bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <local path>

**Parameter Explanation**:
- `<image URL or path>`: Required, URL or local file path of the image to analyze

**Features**:
- Analyze visual style of images
- Generate suitable prompt suggestions
- Recognize colors, composition, and artistic styles
- Save analysis results to `analysis/` directory

**Example**:
```bash

分析在线图片

Analyze online image

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 https://example.com/image.jpg

分析本地图片

Analyze local image

npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts ./template/参考图.png

**使用场景**:
- 学习参考图片的风格特征
- 为图生图准备提示词
- 了解如何描述特定视觉风格
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts ./template/参考图.png

**Usage Scenarios**:
- Learn style features of reference images
- Prepare prompts for image-to-image generation
- Understand how to describe specific visual styles

文件结构

File Structure

项目目录结构

Project Directory Structure

my-image-project/
├── config/
│   └── secrets.md           # API 配置(可选)
├── template/                # PDF 模板图片
├── prompts/                 # 提示词文件
├── analysis/                # 风格分析(可选)
├── images/                  # 生成的图像
└── .gitignore
my-image-project/
├── config/
│   └── secrets.md           # API configuration (optional)
├── template/                # PDF template images
├── prompts/                 # Prompt files
├── analysis/                # Style analysis (optional)
├── images/                  # Generated images
└── .gitignore

Skill 目录结构

Skill Directory Structure

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

pw-image-generation/
├── SKILL.md                  # This file (core documentation)
├── config.example/           # Configuration templates
│   ├── README.md             # Configuration instructions
│   └── secrets.md            # API configuration template
├── references/               # Reference documents
│   ├── .gitignore.template   # Git ignore file template
│   ├── 图床上传.md           # Image hosting upload guide
│   ├── style-library.md      # Style library (9 preset styles)
│   └── prompt-templates/
│       └── 提示词模板.md     # Prompt templates
└── scripts/
    ├── analyze-image.ts      # Analyze image style
    ├── generate-image.ts     # Generate images (supports confirmation and skipping)
    ├── upload-image.ts       # Upload images to hosting service
    ├── delete-image.ts       # Manage and delete hosted images
    ├── merge-to-long-image.ts       # Merge into long image
    └── merge-to-pptx.ts        # Package into PPT

常见问题和错误处理

Common Issues and Error Handling

1. 生成图像失败

1. Image Generation Failure

问题: 图像生成失败或返回错误
可能原因:
  • API 密钥未配置或无效
  • 提示词格式不正确
  • 网络连接问题
  • API 额度不足
解决方案:
bash
undefined
Problem: Image generation fails or returns errors
Possible Causes:
  • API key not configured or invalid
  • Incorrect prompt format
  • Network connection issues
  • Insufficient API credits
Solutions:
bash
undefined

检查配置文件

Check configuration file

cat config/secrets.md
cat config/secrets.md

验证提示词格式

Verify prompt format

cat prompts/提示词.md
cat prompts/提示词.md

测试网络连接

Test network connection

查看详细错误信息 (脚本会自动显示)

View detailed error information (automatically displayed by script)


---

---

2. 图床上传失败

2. Image Hosting Upload Failure

问题: 上传图片到图床失败
可能原因:
  • 图片文件不存在或路径错误
  • 图片格式不支持
  • 图片文件过大 (超过 10MB)
  • 网络连接问题
解决方案:
bash
undefined
Problem: Failed to upload image to hosting service
Possible Causes:
  • Image file does not exist or incorrect path
  • Unsupported image format
  • Image file too large (exceeds 10MB)
  • Network connection issues
Solutions:
bash
undefined

检查文件是否存在

Check if file exists

ls -lh ./template/图片.png
ls -lh ./template/图片.png

检查文件大小

Check file size

du -h ./template/图片.png
du -h ./template/图片.png

如果文件过大,压缩图片

If file is too large, compress it

使用 ImageMagick 压缩

Compress using ImageMagick

convert ./template/图片.png -quality 85 -resize 2000x2000> ./template/图片_compressed.png

---
convert ./template/图片.png -quality 85 -resize 2000x2000> ./template/图片_compressed.png

---

3. 合并长图失败

3. Long Image Merging Failure

问题: 合并长图时报错 "ImageMagick not found"
可能原因:
  • 未安装 ImageMagick
  • ImageMagick 未添加到 PATH
解决方案:
bash
undefined
Problem: Error "ImageMagick not found" when merging long images
Possible Causes:
  • ImageMagick not installed
  • ImageMagick not added to PATH
Solutions:
bash
undefined

macOS 安装

Install on macOS

brew install imagemagick
brew install imagemagick

验证安装

Verify installation

convert --version
convert --version

如果仍然失败,检查 PATH

If still failing, check PATH

which convert

---
which convert

---

4. PPT 生成失败

4. PPT Generation Failure

问题: 生成 PPT 时报错或 PPT 无法打开
可能原因:
  • 图片目录为空或不存在
  • 图片格式不支持
  • 输出文件路径无效
解决方案:
bash
undefined
Problem: Error when generating PPT or PPT cannot be opened
Possible Causes:
  • Image directory is empty or does not exist
  • Unsupported image format
  • Invalid output file path
Solutions:
bash
undefined

检查图片目录

Check image directory

ls -la ./images
ls -la ./images

检查图片格式 (支持 jpg/png/gif/webp)

Check image format (supports jpg/png/gif/webp)

file ./images/*.png
file ./images/*.png

确保输出目录存在

Ensure output directory exists

mkdir -p ./output npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images ./output/配图.pptx

---
mkdir -p ./output npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images ./output/配图.pptx

---

5. 提示词不生效

5. Prompts Not Effective

问题: 生成的图像与提示词描述不符
可能原因:
  • 提示词描述不够具体
  • 提示词语言混乱 (中英文混用)
  • 提示词过长或过短
  • 风格描述不明确
解决方案:
markdown
undefined
Problem: Generated images do not match prompt descriptions
Possible Causes:
  • Prompt descriptions are not specific enough
  • Mixed Chinese and English in prompts
  • Prompts are too long or too short
  • Style descriptions are unclear
Solutions:
markdown
undefined

不好的提示词

Bad prompt

一张图片
A picture

好的提示词

Good prompt

水彩风格,温馨的咖啡馆场景,柔和的光线,暖色调,手绘质感
Watercolor style, a cute kitten sitting on a windowsill, warm afternoon sunlight, soft colors, hand-painted texture

使用风格库

Use style library

参考 references/style-library.md 选择合适的风格描述

---
Refer to references/style-library.md to select appropriate style descriptions

---

6. 批量生成中断

6. Batch Generation Interruption

问题: 批量生成过程中意外中断
可能原因:
  • 网络不稳定
  • 用户手动中断 (Ctrl+C)
  • API 限流
解决方案:
  • 脚本会自动跳过已生成的图像
  • 重新运行生成命令即可继续
  • 已生成的图像不会重复生成
  • 使用
    n
    选项跳过不需要的图像

Problem: Unexpected interruption during batch generation
Possible Causes:
  • Unstable network
  • Manual interruption by user (Ctrl+C)
  • API rate limiting
Solutions:
  • The script will automatically skip already generated images
  • Re-run the generation command to continue
  • Already generated images will not be regenerated
  • Use
    n
    option to skip unwanted images

7. 配置文件问题

7. Configuration File Issues

问题: 配置文件不生效或找不到
可能原因:
  • 配置文件路径错误
  • 配置文件格式不正确
  • 未复制配置模板
解决方案:
bash
undefined
Problem: Configuration file not effective or not found
Possible Causes:
  • Incorrect configuration file path
  • Incorrect configuration file format
  • Configuration template not copied
Solutions:
bash
undefined

复制配置模板

Copy configuration template

cp -r ~/.claude/skills/pw-image-generation/config.example ./config
cp -r ~/.claude/skills/pw-image-generation/config.example ./config

检查配置文件

Check configuration file

cat config/secrets.md
cat config/secrets.md

配置文件格式示例

Configuration file format example

API_KEY=sk-xxx

API_KEY=sk-xxx


---

---

最佳实践

Best Practices

图像尺寸规范

Image Size Specifications

根据不同使用场景选择合适的图像尺寸:
场景比例推荐像素说明
文章配图16:91920×1080高清标准, 适配大屏阅读
公众号封面2.35:1900×383微信官方推荐尺寸
小红书封面/配图3:41242×1660小红书推荐, 适配 iPhone 屏幕
X 文章封面5:21500×600X Articles 官方推荐
论文配图16:91920×1080高清标准
补充说明:
  • 小红书也支持 1:1 (1080×1080) 和 4:3 (1440×1080)
  • 公众号次图封面可用 200×200 (1:1)
使用建议:
  • 在提示词中指定尺寸:
    size: 1920x1080
    aspect_ratio: 16:9
  • 优先使用推荐尺寸, 避免后期裁剪导致构图失衡
  • 不同平台的尺寸要求不同, 生成前确认目标平台

Select appropriate image sizes based on different usage scenarios:
ScenarioAspect RatioRecommended PixelsDescription
Article Illustrations16:91920×1080HD standard, suitable for large-screen reading
WeChat Official Account Cover2.35:1900×383Official WeChat recommended size
Xiaohongshu Cover/Illustrations3:41242×1660Xiaohongshu recommended, suitable for iPhone screens
X Article Cover5:21500×600Official X Articles recommended
Paper Illustrations16:91920×1080HD standard
Additional Notes:
  • Xiaohongshu also supports 1:1 (1080×1080) and 4:3 (1440×1080)
  • WeChat Official Account secondary cover can use 200×200 (1:1)
Usage Suggestions:
  • Specify size in prompts:
    size: 1920x1080
    or
    aspect_ratio: 16:9
  • Prioritize recommended sizes to avoid composition imbalance caused by later cropping
  • Different platforms have different size requirements, confirm target platform before generation

提示词设计

Prompt Design

基本原则:
  • 具体明确: 详细描述场景、风格、颜色、构图
  • 风格统一: 使用风格库中的预设风格描述
  • 语言一致: 全英文或全中文,避免混用
  • 长度适中: 50-200 字为宜,过短缺乏细节,过长容易混乱
推荐结构:
markdown
[风格] + [主体] + [场景] + [氛围] + [技术细节]

示例:
水彩风格,一只可爱的小猫,坐在窗台上,温暖的午后阳光,柔和的色彩,手绘质感
参考资源:
  • references/style-library.md
    : 9 种预设风格
  • references/prompt-templates/提示词模板.md
    : 提示词模板

Basic Principles:
  • Specific and clear: Detailed description of scene, style, color, and composition
  • Consistent style: Use preset style descriptions from the style library
  • Consistent language: All English or all Chinese, avoid mixing
  • Moderate length: 50-200 words is appropriate; too short lacks details, too long is confusing
Recommended Structure:
markdown
[Style] + [Subject] + [Scene] + [Atmosphere] + [Technical Details]

Example:
Watercolor style, a cute kitten sitting on a windowsill, warm afternoon sunlight, soft colors, hand-painted texture
Reference Resources:
  • references/style-library.md
    : 9 preset styles
  • references/prompt-templates/提示词模板.md
    : Prompt templates

图像生成流程

Image Generation Process

推荐步骤:
  1. 先生成 1-2 张测试图像,验证提示词效果
  2. 根据测试结果调整提示词
  3. 确认效果满意后,批量生成剩余图像
  4. 使用确认机制,避免浪费 API 额度
  5. 定期备份生成的图像
避免浪费:
  • 每次生成前仔细检查提示词
  • 使用
    n
    选项跳过不需要的图像
  • 使用
    q
    选项及时退出
  • 不要盲目批量生成

Recommended Steps:
  1. First generate 1-2 test images to verify prompt effectiveness
  2. Adjust prompts based on test results
  3. Batch generate remaining images after confirming satisfactory results
  4. Use confirmation mechanism to avoid wasting API credits
  5. Regularly back up generated images
Avoid Wastage:
  • Carefully check prompts before each generation
  • Use
    n
    option to skip unwanted images
  • Use
    q
    option to exit promptly
  • Do not blindly batch generate

图生图技巧

Image-to-Image Tips

上传参考图:
bash
undefined
Upload Reference Image:
bash
undefined

1. 上传参考图到图床

1. Upload reference image to hosting service

npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png

2. 复制返回的 URL

2. Copy the returned URL

3. 在提示词中使用

3. Use in prompt

prompt: 类似风格的场景,保持色调和构图

prompt: Scene with similar style, maintain color tone and composition


**注意事项**:
- 参考图尺寸建议 1024x1024 或更大
- 参考图清晰度要高
- 提示词要明确说明保留哪些特征
- 可以多次尝试不同的提示词组合

---

**Notes**:
- Recommended reference image size is 1024x1024 or larger
- Reference image should be high-definition
- Prompts should clearly state which features to retain
- Try different prompt combinations multiple times

---

文件管理

File Management

目录结构建议:
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)
命名规范:
  • 提示词文件: 使用数字前缀排序 (01-, 02-, 03-)
  • 生成的图像: 自动使用提示词文件名
  • 便于批量处理和排序

Recommended Directory Structure:
my-image-project/
├── config/              # Configuration files (not submitted to git)
├── template/            # Reference images
├── prompts/             # Prompt files
│   ├── 01-封面.md
│   ├── 02-内容1.md
│   └── 03-内容2.md
├── images/              # Generated images
│   ├── 01-封面.png
│   ├── 02-内容1.png
│   └── 03-内容2.png
└── output/              # Final output (long images/PPTs)
Naming Conventions:
  • Prompt files: Use numeric prefixes for sorting (01-, 02-, 03-)
  • Generated images: Automatically use prompt file names
  • Facilitates batch processing and sorting

性能优化

Performance Optimization

提高生成速度:
  • 使用较小的图像尺寸 (1024x1024 而非 2048x2048)
  • 避免过于复杂的提示词
  • 合理使用图生图 (比文生图更快)
节省 API 额度:
  • 使用确认机制,不要跳过确认
  • 先测试单张,再批量生成
  • 保存好的提示词作为模板复用
  • 定期清理图床上不需要的图片

Improve Generation Speed:
  • Use smaller image sizes (1024x1024 instead of 2048x2048)
  • Avoid overly complex prompts
  • Use image-to-image appropriately (faster than text-to-image)
Save API Credits:
  • Use confirmation mechanism, do not skip confirmation
  • Test single images first, then batch generate
  • Save good prompts as templates for reuse
  • Regularly clean up unnecessary images on hosting service

质量控制

Quality Control

检查清单:
  • 提示词描述清晰具体
  • 风格描述统一一致
  • 测试图像效果满意
  • 图像尺寸和格式正确
  • 文件命名规范有序
  • 备份重要图像
常见问题:
  • 图像风格不一致: 检查提示词中的风格描述
  • 图像质量不佳: 增加技术细节描述 (如 "高清"、"细节丰富")
  • 图像内容偏差: 提示词更具体,增加约束条件

Checklist:
  • Prompt descriptions are clear and specific
  • Style descriptions are unified and consistent
  • Test image results are satisfactory
  • Image size and format are correct
  • File naming is standardized and organized
  • Important images are backed up
Common Issues:
  • Inconsistent image style: Check style descriptions in prompts
  • Poor image quality: Add technical detail descriptions (e.g., "high definition", "rich details")
  • Image content deviation: Make prompts more specific and add constraint conditions

重要提示

Important Notes

避免额度浪费

Avoid Credit Wastage

  • 每次生成前都会询问确认
  • 支持跳过已生成的图像
  • 一张一张生成,避免批量消耗额度
  • Asks for confirmation before each generation
  • Supports skipping already generated images
  • Generate one image at a time to avoid batch credit consumption

配置管理

Configuration Management

  • 配置文件
    config/secrets.md
    是可选的
  • 未配置时使用默认配置 (需要设置环境变量 API_KEY)
  • 配置文件不会提交到版本控制 (已在 .gitignore 中)
  • 支持自定义 API 端点和模型
  • Configuration file
    config/secrets.md
    is optional
  • Uses default configuration when not configured (requires setting environment variable API_KEY)
  • Configuration files are not submitted to version control (already in .gitignore)
  • Supports custom API endpoints and models

运行环境

Runtime Environment

脚本使用 Bun 运行,无需本地安装依赖:
bash
undefined
Scripts run with Bun, no need to install dependencies locally:
bash
undefined

直接运行,Bun 会自动处理依赖

Run directly, Bun will handle dependencies automatically

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

**系统要求**:
- Node.js 或 Bun 运行时
- macOS/Linux/Windows (WSL)
- 合并长图需要 ImageMagick

---
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

**System Requirements**:
- Node.js or Bun runtime
- macOS/Linux/Windows (WSL)
- ImageMagick required for long image merging

---

配置说明

Configuration Instructions

查看
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 密钥 (必需)
配置示例:
markdown
undefined
See
config.example/secrets.md
for configuration options:
Configurable Items:
  • API_BASE_URL
    : API base URL (default: OpenAI API)
  • ANALYSIS_MODEL_ID
    : Image analysis model (default: gpt-4-vision-preview)
  • GENERATION_MODEL_ID
    : Image generation model (default: dall-e-3)
  • API_KEY
    : API key (required)
Configuration Example:
markdown
undefined

config/secrets.md

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

---
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

---

风格库

Style Library

Skill 提供 9 种预设风格,保证图像风格一致性:
  • 水彩风格 (watercolor) - 柔和温馨
  • 扁平化设计 (flat-design) - 现代简洁
  • 3D 渲染 (3d-render) - 立体真实
  • 油画风格 (oil-painting) - 艺术经典
  • 赛博朋克 (cyberpunk) - 科幻未来
  • 像素艺术 (pixel-art) - 复古怀旧
  • 手绘插画 (hand-drawn) - 温暖个性
  • 照片写实 (photorealistic) - 高度真实
  • 抽象艺术 (abstract) - 情感表达
查看
references/style-library.md
了解每种风格的详细说明和使用场景。

The Skill provides 9 preset styles to ensure consistent image styles:
  • Watercolor (watercolor) - Soft and warm
  • Flat Design (flat-design) - Modern and concise
  • 3D Render (3d-render) - Stereoscopic and realistic
  • Oil Painting (oil-painting) - Artistic and classic
  • Cyberpunk (cyberpunk) - Sci-fi and futuristic
  • Pixel Art (pixel-art) - Retro and nostalgic
  • Hand-Drawn Illustration (hand-drawn) - Warm and personalized
  • Photorealistic (photorealistic) - Highly realistic
  • Abstract Art (abstract) - Emotional expression
See
references/style-library.md
for detailed descriptions and usage scenarios of each style.

使用建议

Usage Suggestions

Agent 使用指南

Agent Usage Guide

当用户请求生成图像时:
  1. 确认需求: 询问用户图像用途、风格偏好、数量
  2. 准备环境: 引导用户创建项目目录和配置
  3. 设计提示词: 根据需求设计提示词,参考风格库
  4. 生成测试: 先生成 1-2 张测试图像
  5. 批量生成: 确认效果后批量生成
  6. 后期处理: 根据需要合并长图或打包 PPT
When users request image generation:
  1. Confirm Requirements: Ask users about image usage, style preferences, and quantity
  2. Prepare Environment: Guide users to create project directories and configurations
  3. Design Prompts: Design prompts based on requirements, refer to the style library
  4. Generate Tests: First generate 1-2 test images
  5. Batch Generation: Batch generate after confirming satisfactory results
  6. Post-Processing: Merge into long images or package into PPT as needed

典型工作流

Typical Workflows

场景 1: 文章配图
bash
undefined
Scenario 1: Article Illustrations
bash
undefined

1. 创建项目

1. Create project

mkdir article-images && cd article-images
mkdir article-images && cd article-images

2. 准备提示词

2. Prepare prompts

mkdir prompts
mkdir prompts

创建 prompts/01-封面.md, 02-配图1.md 等

Create prompts/01-封面.md, 02-配图1.md, etc.

3. 生成图像

3. Generate images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

4. 合并长图 (可选)

4. Merge into long image (optional)

npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./images 长图.png

**场景 2: PPT 配图**
```bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./images 长图.png

**Scenario 2: PPT Illustrations**
```bash

1. 创建项目

1. Create project

mkdir ppt-images && cd ppt-images
mkdir ppt-images && cd ppt-images

2. 准备提示词 (按页面顺序命名)

2. Prepare prompts (named in page order)

mkdir prompts
mkdir prompts

创建 prompts/01-标题页.md, 02-内容1.md 等

Create prompts/01-标题页.md, 02-内容1.md, etc.

3. 生成图像

3. Generate images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

4. 打包为 PPT

4. Package into PPT

npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images 配图.pptx

**场景 3: 图生图**
```bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images 配图.pptx

**Scenario 3: Image-to-Image**
```bash

1. 上传参考图

1. Upload reference image

npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png

2. 在提示词中使用返回的 URL

2. Use returned URL in prompt

prompts/01-类似风格.md:

prompts/01-类似风格.md:

prompt: 类似风格的场景,保持色调和构图

prompt: Scene with similar style, maintain color tone and composition

3. 生成图像

3. Generate images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

---
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts

---

命令速查

Command Cheat Sheet

bash
undefined
bash
undefined

生成图像

Generate images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [输出目录]
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [output directory]

上传图片

Upload images

npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <图片路径>
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <image path>

管理图床

Manage hosting service

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/delete-image.ts list npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete <index> npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-all

合并长图

Merge into long image

npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <图片目录> <输出文件>
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <image directory> <output file>

打包 PPT

Package into PPT

npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <图片目录> <输出文件>
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <image directory> <output file>

分析图像

Analyze image

npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <图像URL或路径>
undefined
npx -y bun ~/.claude/skills/pw-image-generation/scripts/analyze-image.ts <image URL or path>
undefined