SuperAPI AI Directory

pw-image-gen

Design & creation

View repository

Updated 10-15 23:56

About this skill

Image-Generation - AI image generation workflow

Core Concept: Analyze style → Design prompt → User confirmation → Generate image, avoid wasting quota

When to Use

Image Generation:

  • Need to generate images based on text descriptions
  • Have reference images and need to generate images in a similar style
  • Need to generate multiple images in batch
  • Want to keep image style consistent but content different

Image Processing:

  • Merge a series of images into one long image (vertical concatenation)
  • Package a series of images into a PPT file (one image per page)

Workflow

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

Quick Start

Step 1: Install Skill dependencies

cd ~/.claude/skills/pw-image-generation && npm install

Step 2: Create project directory

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

Step 3: Copy configuration template (optional)

cp -r ~/.claude/skills/pw-image-generation/config.example ./config
cp ~/.claude/skills/pw-image-generation/references/.gitignore.template ./.gitignore
# 编辑 config/secrets.md 自定义 API 密钥(可选)

Step 4: Create prompt

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 choose an appropriate style.

Step 5: Generate images

node ~/.claude/skills/Image-Generation/scripts/generate-image.js

The script will ask for confirmation one by one to avoid wasting quota.


Tool Scripts

Generate Images

node ~/.claude/skills/pw-image-generation/scripts/generate-image.js [输出目录]

Upload images to image hosting

Upload local images to image hosting to obtain URLs (for image-to-image):

node ~/.claude/skills/pw-image-generation/scripts/upload-image.js <图片路径>

# 示例
node ~/.claude/skills/pw-image-generation/scripts/upload-image.js ./template/图.001.png

Features:

  • Automatically upload to freeimage.host (permanent storage)
  • Return usable image URL
  • Automatically save deletion link to .upload-history.json
  • For uploading reference images for image-to-image

Manage Image Hosting Images

View and delete uploaded images:

# 列出所有上传的图片
node ~/.claude/skills/pw-image-generation/scripts/delete-image.js list

# 删除指定索引的图片
node ~/.claude/skills/pw-image-generation/scripts/delete-image.js delete 0

# 删除所有图片
node ~/.claude/skills/pw-image-generation/scripts/delete-image.js delete-all

Features:

  • View upload history and deletion links
  • Delete images individually or in batch
  • Automatically update history records

See detailed instructions in references/图床上传.md

Merge Long Images

Merge a series of images into one long image (vertical concatenation):

node ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.js <图片目录> <输出文件>

# 示例
node ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.js ./images 长图.png

Requirements: Requires ImageMagick installed

brew install imagemagick

Merge into PPT

Package a series of images into a PPT file (one image per page):

node ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.js <图片目录> <输出文件>

# 示例
node ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.js ./images 配图.pptx

Features:

  • Automatically recognize jpg/png/gif/webp formats
  • Sort by numerical order of filenames
  • Each image occupies one page, 16:9 ratio
  • Automatically adapt to page size

File Structure

Project Directory Structure

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

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.js      # 分析图像风格
│   ├── generate-image.js     # 生成图像(支持确认和跳过)
│   ├── upload-image.js       # 上传图片到图床
│   ├── delete-image.js       # 管理和删除图床图片
│   ├── merge-to-long-image.js       # 合并长图
│   └── merge-to-pptx.js        # 打包为 PPT
├── node_modules/
├── package.json
└── package-lock.json

Important Notes

Avoid Wasting Quota

  • Ask for confirmation before each generation
  • Support skipping already generated images
  • Generate one by one to avoid consuming quota in batch

Configuration Management

  • Configuration file config/secrets.md is optional
  • Use default configuration when not configured (API_KEY needs to be set)
  • Configuration files will not be committed to version control

Dependency Installation

Dependencies are installed in the skill directory, not the project directory:

cd ~/.claude/skills/pw-image-generation && npm install

Command Reference

Analyze image style (optional)

# 从 URL 分析
node ~/.claude/skills/pw-image-generation/scripts/analyze-image.js <图像URL>

# 从本地文件分析
node ~/.claude/skills/pw-image-generation/scripts/analyze-image.js <本地路径>

Generate images

node ~/.claude/skills/pw-image-generation/scripts/generate-image.js [输出目录]

Style Library

The Skill provides 9 preset styles to ensure image style consistency:

  • Watercolor style (watercolor) - soft and warm
  • Flat design (flat-design) - modern and concise
  • 3D Render (3d-render) - Dimensional and Realistic
  • Oil Painting Style (oil-painting) - Artistic Classic
  • Cyberpunk (cyberpunk) - Sci-Fi Future
  • Pixel Art (pixel-art) - Retro Nostalgia
  • Hand-Drawn Illustration (hand-drawn) - Warm and Personal
  • Photorealistic (photorealistic) - Highly Realistic
  • Abstract Art (abstract) - Emotional Expression

View references/style-library.md to learn detailed descriptions and use cases for each style.


Configuration Instructions

View config.example/secrets.md to learn about configuration options:

  • API_BASE_URL: API base URL
  • ANALYSIS_MODEL_ID: Image analysis model
  • GENERATION_MODEL_ID: Image generation model
  • API_KEY: API key

Best Practices

  1. Test a single image first, and after confirming the prompt effect, generate in batches
  2. Use the confirmation mechanism; do not skip the confirmation step
  3. Save good prompts as templates
  4. Regularly back up generated images