Loading...
Loading...
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.
npx skill4agent add plugins-world/pw-skills pw-image-generationCore Concept: Analyze Style → Design Prompts → User Confirmation → Generate Images, Avoid Credit Wastage
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/~/.claude/skills/pw-image-generation/scripts/SKILL_DIR${SKILL_DIR}/scripts/<script-name>.ts${SKILL_DIR}| 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 | |
mkdir my-image-project && cd my-image-projectcp -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)mkdir -p prompts
cp ~/.claude/skills/pw-image-generation/references/prompt-templates/提示词模板.md ./prompts/我的提示词.md
vim ./prompts/我的提示词.mdreferences/style-library.mdnpx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.tsnpx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.ts [output directory][output directory]./imagesprompts/ynq# 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-imagesnpx -y bun ~/.claude/skills/pw-image-generation/scripts/upload-image.ts <image path><image path>.upload-history.json# 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)Upload successful!
Image URL: https://iili.io/xxx.png
Deletion link saved to .upload-history.json# 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-alllistdelete <index>delete-all# 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-allreferences/图床上传.mdnpx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-long-image.ts <image directory> <output file><image directory><output file>brew install imagemagick# 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 合集.jpgnpx -y bun ~/.claude/skills/pw-image-generation/scripts/merge-to-pptx.ts <image directory> <output file><image directory><output file># 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 展示.pptx# 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><image URL or path>analysis/# 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/参考图.pngmy-image-project/
├── config/
│ └── secrets.md # API configuration (optional)
├── template/ # PDF template images
├── prompts/ # Prompt files
├── analysis/ # Style analysis (optional)
├── images/ # Generated images
└── .gitignorepw-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# 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)# 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.png# Install on macOS
brew install imagemagick
# Verify installation
convert --version
# If still failing, check PATH
which convert# 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/配图.pptx# 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 descriptionsn# 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-xxx| 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 |
size: 1920x1080aspect_ratio: 16:9[Style] + [Subject] + [Scene] + [Atmosphere] + [Technical Details]
Example:
Watercolor style, a cute kitten sitting on a windowsill, warm afternoon sunlight, soft colors, hand-painted texturereferences/style-library.mdreferences/prompt-templates/提示词模板.mdnq# 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 compositionmy-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)config/secrets.md# Run directly, Bun will handle dependencies automatically
npx -y bun ~/.claude/skills/pw-image-generation/scripts/generate-image.tsconfig.example/secrets.mdAPI_BASE_URLANALYSIS_MODEL_IDGENERATION_MODEL_IDAPI_KEY# 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-herereferences/style-library.md# 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 长图.png# 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 配图.pptx# 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.ts# 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>