SuperAPI AI Directory

article-batch-illustration

Writing & research

View repository

Updated 10-16 04:45

About this skill

Batch Article Illustration

Analyze the structure of a Markdown article, generate illustration prompts for each paragraph/section, call the Gemini API to batch-generate images and insert them into the document.

Workflow

Phase 1: Analyze article → Generate prompts

  1. Read article - Get the article content provided by the user (currently open file or specified path)
  2. Structure analysis - Split paragraphs by H2/H3 headings, extract the core idea of each paragraph
  3. Generate style instructions - Generate a global STYLE INSTRUCTIONS code block based on the article topic
  4. Generate prompts - Create an image prompt outline for each paragraph (refer to references/style-guide.md)
  5. Display and confirm - Display all prompts as a list, wait for user confirmation or modification

Phase 2: Generate images → Insert into document

  1. Batch generation - Call scripts/generate_image.py to generate images one by one
  2. Save images - Save to the obsidian/09image/MMDD-主题名称/ directory
  3. Insert into document - Insert after each paragraph heading ![[图片路径]] reference

Phase 1 Detailed Guide

1. Article structure analysis

After reading the article, split it according to the following rules:

  • Use ## (H2) or ### (H3) headings as paragraph separators
  • Ignore the frontmatter (YAML) section
  • Ignore auxiliary content such as pure quotes and footnotes
  • Extract for each paragraph: heading, core viewpoint (1 sentence), key concepts (3-5 words)

Output format:

## 文章结构分析

| # | 段落标题 | 核心观点 | 关键概念 |
|---|---------|---------|---------|
| 1 | xxx     | xxx     | A, B, C |
| 2 | xxx     | xxx     | D, E, F |

2. Generate global style instructions

Before all prompts, a STYLE INSTRUCTIONS block must first be generated. Read references/style-guide.md to get the style template.

Use by defaultStyle 1 (minimalist hand-drawn style), the user can choose Style 2 (architectural blueprint editorial style).

STYLE INSTRUCTIONS:
- 整体风格: 简约手绘风格 / 建筑蓝图编辑风格
- 色彩方案: 白底为主,黑色线条,[主题点缀色]
- 比例: 16:9 横版
- 分辨率: 2K
- 文字量: 极少,仅保留1-3个核心关键词
- 文字语言: 图片中文字以简体中文为主,专业术语/缩写(如 AI、API、LLM)可保留英文
- 视觉语言: 逻辑图、流程图、概念图
- 一致性: 统一线条粗细、留白比例、排版网格

3. Generate a prompt for each paragraph

Structure of each prompt:

  1. Style prefix - General description from STYLE INSTRUCTIONS
  2. Diagram type - Concept diagram/flowchart/comparison diagram/hierarchy diagram/relationship diagram
  3. Content description - Focus on the core idea of the paragraph, describe the diagram content in narrative language
  4. Chinese labels - Write Chinese keywords directly (such as "data collection", "intelligent processing"), 1-3 of them
  5. Chinese-primary instruction(required) - Append at the end of each prompt:ALL text, labels, and annotations in the image MUST be primarily in Chinese (Simplified Chinese, 中文). Use clean Chinese font for main text. Technical terms and abbreviations (e.g. AI, API, LLM, RAG) may remain in English.
  6. Exclusions - "No photography, no realistic elements, no complex gradients"

Display format (waiting for user confirmation):

## 提示词大纲

### 图 1: [段落标题]
- 图表类型: 概念图
- 提示词:
  """
  [完整英文提示词]
  """

### 图 2: [段落标题]
...

Key:

  • The main body of the prompt should be written in English (Gemini understands English prompts better)
  • Text labels that need to appear in the image should be written directly in the original Chinese (such as The central node labeled "AI生产力系统")
  • Each prompt must end with a Chinese-primary instruction,Ensure that the text in the images is primarily in Chinese; technical terms may remain in English

4. Wait for confirmation

After displaying all prompts, ask the user:

  • "Are you satisfied with the above prompts? Does any image description need to be modified?"
  • "After confirmation, batch image generation will begin (N images in total)"
  • The user may specify a different style for a certain image or modify its description

Phase 2 Detailed Guide

5. Call the API to generate images

After confirmation, call the script one by one to generate images:

python3 scripts/generate_image.py \
  --prompt "提示词内容" \
  --output "/Users/ugreen/Documents/obsidian/09image/MMDD-主题名/01-段落名.png" \
  --provider labnana \
  --aspect-ratio "16:9" \
  --resolution "2K"

Notes:

  • For MMDD, use the current date (e.g., 0206)
  • Extract the topic name from the article H1 title and simplify it into a short name
  • Use a two-digit image number (01, 02, 03...)
  • After each image is generated, check the script output to confirm success
  • If an image fails, record it and continue to the next one, then report the failed items at the end
  • Leave an interval of 2-3 seconds between images to avoid API rate limiting

6. Save path specification

/Users/ugreen/Documents/obsidian/09image/MMDD-主题简称/
├── 01-段落标题简称.png
├── 02-段落标题简称.png
├── 03-段落标题简称.png
└── ...

7. Insert into the document

Insert the image reference below the corresponding paragraph heading in the article:

## 段落标题

![[09image/MMDD-主题简称/01-段落标题简称.png]]

段落正文内容...

Use the Obsidian wikilink format ![[路径]] to insert.

API Configuration

LabNana API (default - gpt-image-2)

Configuration Item Value
API URL https://api.labnana.com
API Key Stored in the .labnana.env file
Model gpt-image-2
Provider openai
Default aspect ratio 16:9
Default resolution 2K

Example call:

python3 scripts/generate_image.py \
  --prompt "提示词内容" \
  --output "/path/to/output.png" \
  --provider labnana \
  --aspect-ratio "16:9" \
  --resolution "2K"

Gemini API (backup)

Configuration Item Value
API URL https://generativelanguage.googleapis.com
API Key REMOVED_GEMINI_KEY
Model gemini-3-pro-image-preview
Default aspect ratio 16:9
Default resolution 2K

Example call:

python3 scripts/generate_image.py \
  --prompt "提示词内容" \
  --output "/path/to/output.png" \
  --provider gemini \
  --api-key "GEMINI_API_KEY" \
  --aspect-ratio "16:9" \
  --resolution "2K"

Style Selection

Style Features Applicable Scenarios
Style 1 (Default) Minimalist hand-drawn, black lines, white background General, concept explanation, process description
Style 2 Architectural blueprint/technical journal, refined and minimalist System architecture, technical analysis, professional content

The user can choose a global style during the confirmation stage, or specify a different style for an individual image.

Common Usage

User says Action
"Add images to this article" Analyze the currently open article and add images in batch
"Batch add images" Same as above
"Add images to the article using Style 2" Use the architectural blueprint editing style
"Modify the prompt for the 3rd image" Regenerate the specified image
"Regenerate the 2nd image" Call the API again with the modified prompt