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

NPX Install

npx skill4agent add lovstudio/skills lovstudio-document-illustrator

SKILL.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 cleanup

Step 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:
  1. Use the Read tool to read the complete document
  2. AI analyzes content structure and identifies core topics
  3. Determine precise insertion anchors (line number + contextual text) for each topic
  4. 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 summary
Key: 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:
  1. Agent completes → Obtain image path
  2. Locate the insertion position in the original document via anchor text (not dependent on line numbers)
  3. Use the Edit tool to insert Markdown image reference after the anchor:
    markdown
    ![Topic description](images/illustration-01.png)
  4. 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.,
    ## Birth of Rules
    ) instead of line numbers for positioning
  • 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:
  1. Verification: Check that all planned
    ![...]()
    references have been inserted into the original document
  2. Verification: Check that all image files exist in the
    images/
    directory
  3. Success → Delete the backup file
    {doc_path}.illustrator-backup
  4. 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 up

Configuration Options

Claude will ask (or infer from user messages) before execution:
OptionValuesDefault
Image Aspect Ratio16:9 / 3:416:9
Include Cover ImageYes/NoNo
Number of Content Illustrations3-10Recommended based on document length
Stylegradient-glass / ticket / vector-illustrationgradient-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

StyleKeywordsSuitable For
gradient-glassGlass morphism, aurora gradient, tech vibeTechnical documents, product introductions
ticketBlack-white contrast, ticket structure, minimalismData reports, infographics
vector-illustrationFlat illustration, retro color scheme, geometricTutorials, stories, branding
Style files are located in the
styles/
directory.

Technical Details

ItemValue
API ModelGemini 2.0 Flash Image Preview
16:9 Resolution2560x1440 (2K) / 3840x2160 (4K)
3:4 Resolution1920x2560 (2K) / 2880x3840 (4K)
Single Image Time~10-20s
Parallel Processing Time~10-20s (total, not multiplied by N)
Dependencies
pip install google-genai pillow python-dotenv
API Key
GEMINI_API_KEY
in
.env
or environment variable

Scripts

  • scripts/generate_single_image.py
    — Single image generation (for parallel Agent calls)
  • scripts/generate_illustrations.py
    — Legacy batch sequential generation (retained for compatibility)