pw-image-generation
Original:🇨🇳 Chinese
Translated
6 scripts
AI Image Generation and Processing Workflow. Generate images via prompts, supporting text-to-image, image-to-image, batch generation, image hosting management, long image merging, and PPT packaging. The core feature is generating images with one-by-one confirmation to avoid wasting API credits.
11installs
Sourceplugins-world/pw-skills
Added on
NPX Install
npx skill4agent add plugins-world/pw-skills pw-image-generationTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Image-Generation - AI Image Generation Workflow
Core Concept: Analyze Style → Design Prompts → User Confirmation → Generate Images, Avoid Credit Wastage
Core Features
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
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
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
All scripts are located in the directory.
~/.claude/skills/pw-image-generation/scripts/Agent Execution Instructions:
- Determine the directory path of this SKILL.md file as
SKILL_DIR - Script path =
${SKILL_DIR}/scripts/<script-name>.ts - Replace all in this document with the actual path
${SKILL_DIR}
Available Scripts:
| Script | Function | Parameters |
|---|---|---|
| Generate images (with one-by-one confirmation) | |
| Upload images to hosting service | |
| Manage hosted images | |
| Merge into long image | |
| Package into PPT | |
| Analyze image style | |
Quick Start
Step 1: Create Project Directory
bash
mkdir my-image-project && cd my-image-projectStep 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
# Edit config/secrets.md to customize API keys (optional)Step 3: Create Prompts
bash
mkdir -p prompts
cp ~/.claude/skills/pw-image-generation/references/prompt-templates/提示词模板.md ./prompts/我的提示词.md
vim ./prompts/我的提示词.mdRefer to to select appropriate styles.
references/style-library.mdStep 4: Generate Images
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.tsThe script will ask for confirmation for each image to avoid credit waste.
Tool Script Details
1. Generate Images
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [output directory]Parameter Explanation:
- : Optional, specify the image save directory, default is
[output directory]./images
Workflow:
- Read all prompt files in the directory
prompts/ - Display each prompt content one by one
- Ask whether to generate the image (y/n/q)
- Generate and save the image to the output directory
- Support interruption and resumption
Confirmation Options:
- (yes): Generate current image
y - (no): Skip current image and continue to the next
n - (quit): Exit the generation process
q
Examples:
bash
# Use default output directory
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-images2. Upload Images to Hosting Service
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <image path>Parameter Explanation:
- : Required, path to the local image file to upload
<image path>
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
# Upload single image
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# After upload, you will get:
# - Image URL (used for image_url in prompts)
# - Deletion link (saved in history)Output Example:
Upload successful!
Image URL: https://iili.io/xxx.png
Deletion link saved to .upload-history.json3. Manage Hosted Images
Command:
bash
# List all uploaded images
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 <index>
# Delete all images
npx -y bun ~/.claude/skills/pw-image-generation/scripts/delete-image.ts delete-allParameter Explanation:
- : List all upload records
list - : Delete image with specified index (index starts from 0)
delete <index> - : Delete all images
delete-all
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
# Output:
# 0: 参考图.png - https://iili.io/xxx.png (2024-01-15)
# 1: 配图1.png - https://iili.io/yyy.png (2024-01-16)
# Delete image with index 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-allFor detailed instructions, see
references/图床上传.md4. Merge into Long Image
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <image directory> <output file>Parameter Explanation:
- : Required, directory containing images to merge
<image directory> - : Required, filename of the output long image
<output file>
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 imagemagickExample:
bash
# Merge all images in images directory
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 合集.jpgUsage Scenarios:
- Create long images for Xiaohongshu/WeChat Official Accounts
- Merge series tutorial screenshots
- Create image collection displays
5. Package into PPT
Command:
bash
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <image directory> <output file>Parameter Explanation:
- : Required, directory containing images to package
<image directory> - : Required, filename of the output PPT
<output file>
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
# Package images in images directory into PPT
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 展示.pptxUsage Scenarios:
- Quickly create image demonstration PPTs
- Package series illustrations for sharing
- Organize generated images into presentation documents
6. Analyze Image Style
Command:
bash
# Analyze from 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 <local path>Parameter Explanation:
- : Required, URL or local file path of the image to analyze
<image URL or path>
Features:
- Analyze visual style of images
- Generate suitable prompt suggestions
- Recognize colors, composition, and artistic styles
- Save analysis results to directory
analysis/
Example:
bash
# Analyze online image
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/参考图.pngUsage 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 configuration (optional)
├── template/ # PDF template images
├── prompts/ # Prompt files
├── analysis/ # Style analysis (optional)
├── images/ # Generated images
└── .gitignoreSkill Directory Structure
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 PPTCommon Issues and Error Handling
1. Image Generation Failure
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
# Check configuration file
cat config/secrets.md
# Verify prompt format
cat prompts/提示词.md
# Test network connection
curl -I https://api.openai.com
# View detailed error information (automatically displayed by script)2. Image Hosting Upload Failure
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
# Check if file exists
ls -lh ./template/图片.png
# Check file size
du -h ./template/图片.png
# If file is too large, compress it
# Compress using ImageMagick
convert ./template/图片.png -quality 85 -resize 2000x2000\> ./template/图片_compressed.png3. Long Image Merging Failure
Problem: Error "ImageMagick not found" when merging long images
Possible Causes:
- ImageMagick not installed
- ImageMagick not added to PATH
Solutions:
bash
# Install on macOS
brew install imagemagick
# Verify installation
convert --version
# If still failing, check PATH
which convert4. PPT Generation Failure
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
# Check image directory
ls -la ./images
# Check image format (supports jpg/png/gif/webp)
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/配图.pptx5. Prompts Not Effective
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
# 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
Refer to references/style-library.md to select appropriate style descriptions6. Batch Generation Interruption
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 option to skip unwanted images
n
7. Configuration File Issues
Problem: Configuration file not effective or not found
Possible Causes:
- Incorrect configuration file path
- Incorrect configuration file format
- Configuration template not copied
Solutions:
bash
# Copy configuration template
cp -r ~/.claude/skills/pw-image-generation/config.example ./config
# Check configuration file
cat config/secrets.md
# Configuration file format example
# API_BASE_URL=https://api.openai.com/v1
# API_KEY=sk-xxxBest Practices
Image Size Specifications
Select appropriate image sizes based on different usage scenarios:
| Scenario | Aspect Ratio | Recommended Pixels | Description |
|---|---|---|---|
| Article Illustrations | 16:9 | 1920×1080 | HD standard, suitable for large-screen reading |
| WeChat Official Account Cover | 2.35:1 | 900×383 | Official WeChat recommended size |
| Xiaohongshu Cover/Illustrations | 3:4 | 1242×1660 | Xiaohongshu recommended, suitable for iPhone screens |
| X Article Cover | 5:2 | 1500×600 | Official X Articles recommended |
| Paper Illustrations | 16:9 | 1920×1080 | HD 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: or
size: 1920x1080aspect_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
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 textureReference Resources:
- : 9 preset styles
references/style-library.md - : Prompt templates
references/prompt-templates/提示词模板.md
Image Generation Process
Recommended Steps:
- First generate 1-2 test images to verify prompt effectiveness
- Adjust prompts based on test results
- Batch generate remaining images after confirming satisfactory results
- Use confirmation mechanism to avoid wasting API credits
- Regularly back up generated images
Avoid Wastage:
- Carefully check prompts before each generation
- Use option to skip unwanted images
n - Use option to exit promptly
q - Do not blindly batch generate
Image-to-Image Tips
Upload Reference Image:
bash
# 1. Upload reference image to hosting service
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# 2. Copy the returned URL
# 3. Use in prompt
# image_url: https://iili.io/xxx.png
# prompt: Scene with similar style, maintain color tone and compositionNotes:
- 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
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
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
- Configuration file is optional
config/secrets.md - 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
Scripts run with Bun, no need to install dependencies locally:
bash
# Run directly, Bun will handle dependencies automatically
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.tsSystem Requirements:
- Node.js or Bun runtime
- macOS/Linux/Windows (WSL)
- ImageMagick required for long image merging
Configuration Instructions
See for configuration options:
config.example/secrets.mdConfigurable Items:
- : API base URL (default: OpenAI API)
API_BASE_URL - : Image analysis model (default: gpt-4-vision-preview)
ANALYSIS_MODEL_ID - : Image generation model (default: dall-e-3)
GENERATION_MODEL_ID - : API key (required)
API_KEY
Configuration Example:
markdown
# 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-hereStyle Library
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 for detailed descriptions and usage scenarios of each style.
references/style-library.mdUsage Suggestions
Agent Usage Guide
When users request image generation:
- Confirm Requirements: Ask users about image usage, style preferences, and quantity
- Prepare Environment: Guide users to create project directories and configurations
- Design Prompts: Design prompts based on requirements, refer to the style library
- Generate Tests: First generate 1-2 test images
- Batch Generation: Batch generate after confirming satisfactory results
- Post-Processing: Merge into long images or package into PPT as needed
Typical Workflows
Scenario 1: Article Illustrations
bash
# 1. Create project
mkdir article-images && cd article-images
# 2. Prepare prompts
mkdir prompts
# Create prompts/01-封面.md, 02-配图1.md, etc.
# 3. Generate images
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 4. Merge into long image (optional)
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts ./images 长图.pngScenario 2: PPT Illustrations
bash
# 1. Create project
mkdir ppt-images && cd ppt-images
# 2. Prepare prompts (named in page order)
mkdir prompts
# Create prompts/01-标题页.md, 02-内容1.md, etc.
# 3. Generate images
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts
# 4. Package into PPT
npx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts ./images 配图.pptxScenario 3: Image-to-Image
bash
# 1. Upload reference image
npx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts ./template/参考图.png
# 2. Use returned URL in prompt
# prompts/01-类似风格.md:
# image_url: https://iili.io/xxx.png
# prompt: Scene with similar style, maintain color tone and composition
# 3. Generate images
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.tsCommand Cheat Sheet
bash
# Generate images
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 <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 <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 <image directory> <output file>
# Package into PPT
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 <image URL or path>