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 the article → Generate prompts
- Read the article - Get the article content provided by the user (the currently open file or a specified path)
- Structure analysis - Split paragraphs by H2/H3 headings, extract the core idea of each paragraph
- Generate style instructions - Generate a global STYLE INSTRUCTIONS code block based on the article topic
- Generate prompts - Create an image prompt outline for each paragraph (refer to references/style-guide.md)
- Display and confirm - Display all prompts as a list, wait for the user to confirm or modify
Phase 2: Generate images → Insert into the document
- Batch generation - Call
scripts/generate_image.pyto generate images one by one - Save images - Save to the
obsidian/09image/MMDD-主题名称/directory - Insert into the 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 may 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:
- Style prefix - General description from STYLE INSTRUCTIONS
- Diagram type - Concept diagram/flowchart/comparison diagram/hierarchy diagram/relationship diagram
- Content description - Focus on the paragraph's core idea, describe the diagram content in narrative language
- Chinese labels - Write Chinese keywords directly (such as "data collection", "intelligent processing"), 1-3 of them
- 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. - Exclusions - "No photography, no realistic elements, no complex gradients"
Display format (wait for user confirmation):
## 提示词大纲
### 图 1: [段落标题]
- 图表类型: 概念图
- 提示词:
"""
[完整英文提示词]
"""
### 图 2: [段落标题]
...
Key:
- Write the main body of the prompt in English (Gemini understands English prompts better)
- Write text labels that need to appear in the image directly in the original Chinese (such as
The central node labeled "AI生产力系统") - Each prompt must end with a Chinese-primary instruction, ensure the text in the image is primarily in Chinese; technical terms may be kept in English
4. Wait for confirmation
After displaying all prompts, ask the user:
- "Are you satisfied with the above prompts? Do any image descriptions need to be modified?"
- "Once confirmed, batch image generation will begin (N images total)"
- The user may specify a different style for a particular 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" \
--api-key "REMOVED_GEMINI_KEY" \
--api-url "https://generativelanguage.googleapis.com" \
--model "gemini-3-pro-image-preview" \
--aspect-ratio "16:9" \
--resolution "2K"
Notes:
- MMDD takes the current date (e.g., 0206)
- Extract the topic name from the article's H1 title and simplify it into a short name
- Image number as two digits (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 a 2-3 second interval 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 Document
Insert the image reference below the corresponding section heading in the article:
## 段落标题
![[09image/MMDD-主题简称/01-段落标题简称.png]]
段落正文内容...
Use the Obsidian wikilink format ![[路径]] to insert.
API Configuration
| 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 |
Style Selection
| Style | Characteristics | 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 may 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 image 3" | Regenerate the specified image |
| "Regenerate image 2" | Call the API again with the modified prompt |