lovstudio-document-illustrator
Original:🇨🇳 Chinese
Translated
2 scripts
Insert AI illustrations into documents in-place. After reading the document, plan insertion points globally, generate all images in parallel, and insert them back into the original document asynchronously. Supports cover images, custom aspect ratios, and three styles. Use when: Users request to generate illustrations for documents/articles/notes. Also trigger when user mentions: add illustrations, illustrations, illustration, generate images, document images, add images to articles.
4installs
Sourcelovstudio/skills
Added on
NPX Install
npx skill4agent add lovstudio/skills lovstudio-document-illustratorTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Document Illustrator Skill
An AI-powered document illustration generation tool based on intelligent analysis. Global planning, parallel generation, asynchronous insertion, efficiently add illustrations to documents.
Core Workflow (5 Steps)
Backup → Global insertion point planning → Parallel image generation → Asynchronous insertion into original document → Backup cleanupStep 0: Backup Original File
Create a backup before modification to ensure safe rollback:
python
import shutil
backup_path = f"{doc_path}.illustrator-backup"
shutil.copy2(doc_path, backup_path)All subsequent operations are performed directly on the original file.
Step 1: Globally Determine All Insertion Positions
Read the complete document and plan all image insertion positions in one go:
- Use the Read tool to read the complete document
- AI analyzes content structure and identifies core topics
- Determine precise insertion anchors (line number + contextual text) for each topic
- Output an insertion plan:
Insertion Plan:
[1] After line 15 | Anchor: "## Birth of Rules" | Topic: Evolution of Rules
[2] After line 42 | Anchor: "## Commands Packaging" | Topic: Workflow packaging
[3] After line 78 | Anchor: "## MCP Dynamic Capabilities" | Topic: Third-party integration
...
[cover] Before line 1 | Cover image | Topic: Full document summaryKey: Use contextual text (instead of pure line numbers) as insertion anchors, so even if previous insertions cause line number shifts, subsequent insertions can still be positioned via anchors.
Step 2: Generate All Images in Parallel
Use Agent tools to launch all image generation subtasks in parallel:
For each item in the insertion plan, start an Agent simultaneously:
Agent 1: generate_single_image.py --title "..." --content "..." --output images/illustration-01.png
Agent 2: generate_single_image.py --title "..." --content "..." --output images/illustration-02.png
Agent 3: generate_single_image.py --title "..." --content "..." --output images/illustration-03.png
...- All Agents execute concurrently without waiting for each other
- Each Agent returns the image path or error message upon completion
- Expected total time = time for single image (10-20s), not N * time for single image
Step 3: Asynchronously Insert into Original Document
Insert immediately after each Agent completes, without waiting for other Agents:
- Agent completes → Obtain image path
- Locate the insertion position in the original document via anchor text (not dependent on line numbers)
- Use the Edit tool to insert Markdown image reference after the anchor:
markdown
 - Insertion uses anchor text matching, so previous insertions do not affect subsequent positioning
Position Shift Handling:
- Each insertion increases the number of document lines
- Use anchor text (e.g., ) instead of line numbers for positioning
## Birth of Rules - Inserting from the end of the document to the beginning can also avoid offset issues
Step 4: Verification and Cleanup
After all images are inserted:
- Verification: Check that all planned references have been inserted into the original document
![...]() - Verification: Check that all image files exist in the directory
images/ - Success → Delete the backup file
{doc_path}.illustrator-backup - Failure → Keep the backup file, report which images failed to generate/insert, and users can restore using the backup
Completed: 6/6 illustrations have been inserted into the original document
Backup file cleaned upConfiguration Options
Claude will ask (or infer from user messages) before execution:
| Option | Values | Default |
|---|---|---|
| Image Aspect Ratio | 16:9 / 3:4 | 16:9 |
| Include Cover Image | Yes/No | No |
| Number of Content Illustrations | 3-10 | Recommended based on document length |
| Style | gradient-glass / ticket / vector-illustration | gradient-glass |
If the user has specified in the request (e.g., "portrait, ticket style, 8 images"), use the specified values directly without asking.
Style Quick Reference
| Style | Keywords | Suitable For |
|---|---|---|
| gradient-glass | Glass morphism, aurora gradient, tech vibe | Technical documents, product introductions |
| ticket | Black-white contrast, ticket structure, minimalism | Data reports, infographics |
| vector-illustration | Flat illustration, retro color scheme, geometric | Tutorials, stories, branding |
Style files are located in the directory.
styles/Technical Details
| Item | Value |
|---|---|
| API Model | Gemini 2.0 Flash Image Preview |
| 16:9 Resolution | 2560x1440 (2K) / 3840x2160 (4K) |
| 3:4 Resolution | 1920x2560 (2K) / 2880x3840 (4K) |
| Single Image Time | ~10-20s |
| Parallel Processing Time | ~10-20s (total, not multiplied by N) |
| Dependencies | |
| API Key | |
Scripts
- — Single image generation (for parallel Agent calls)
scripts/generate_single_image.py - — Legacy batch sequential generation (retained for compatibility)
scripts/generate_illustrations.py