Analyze the Markdown article structure, and by default call Codex's built-in image_gen tool (image2) to generate WeChat official account visual assets. When the user says "make a cover image/generate a cover", generate only one cover; when the user says "make illustrations/batch illustrations/illustrate the article", generate multiple illustrations for each paragraph/section and insert them into the document. The old API scripts are only used when the user explicitly requests a CLI/API fallback.
Routing Rules
| User Intent | Output | Style Reference | Default Ratio |
|---|---|---|---|
| Make a cover image / generate a cover / cover image | 1 cover image | references/cover-style.md |
2.35:1 |
| Make illustrations / batch illustrations / illustrate the article / article illustrations | Multiple paragraph illustrations | references/style-guide.md |
16:9 |
If the user requests both "a cover image and illustrations", generate the cover image first, then enter the batch illustration process.
Cover Image Workflow
Cover Phase 1: Extract Cover Information
- Read the article - Get the article content provided by the user (currently open file, specified path, or pasted text)
- Determine the title - Use the title explicitly given by the user; if there is no title, distill one from the article's H1 or core theme
- Extract the top small text - Use the small text specified by the user; if the user does not specify it, leave it empty by default, and do not fabricate the number of articles
- Sort out the full-text logic - Distill 5-7 process nodes for the system diagram on the right side/bottom of the cover
- Read the cover style - Use
references/cover-style.md
Cover Phase 2: Generate 1 Cover Image
Call Codex's built-in image_gen tool to generate a single cover. The cover must follow:
- Ratio: 2.35:1 horizontal wide cover
- Background: White background or warm white background
- Layout: Large title on the left, full-text logic system diagram on the right/bottom
- Title: The title given by the user must be complete, prominent, black, bold, and readable
- Top small text: When specified by the user, it must be presented verbatim, for example
空格的第 205 篇原创文章 - Visual language: ASCII/engineering blueprint style, blue dashed connections, dot-matrix grid, UI cards, folders, terminals, process nodes
- Output quantity: Generate only 1
Before calling the tool, organize the cover prompt into a complete specification:
Use case: ads-marketing
Asset type: WeChat article cover
Primary request: [标题 + 文章核心逻辑 + 顶部小字]
Aspect ratio: 2.35:1 wide cover
Style reference: white background, bold Chinese editorial typography, ASCII/technical blueprint details, blue dashed connector lines, dotted guide grids, small UI cards, clean creator-tool aesthetic
Layout: title on the left half, workflow/system diagram on the right and lower area
Text policy: Chinese text must be accurate and readable. The title and top small text must appear exactly as requested.
Avoid: dark background, photorealistic people, brand logos, clutter, watermark, illegible tiny text
Cover Saving Specification
Save the cover image to the current Obsidian vault:
/path/to/current/obsidian-vault/09 image/MMDD-主题简称/
└── 00-cover-主题简称.png
If image_gen the output ratio is not strictly 2.35:1, it is allowed to add white margins to 2.35:1 without cropping the main subject of the image, and save it separately as 00-cover-主题简称-2.35.png。
Illustration Workflow
Phase 1: Analyze the article → Generate prompts
- Read the article - Get the article content provided by the user (currently open file or 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 in a list, wait for user confirmation or modifications
Phase 2: Generate Images → Insert into Document
- Batch Generation - Use Codex built-in
image_gentool to generate images one by one - Save Images - Copy/move the generated results to the
09 image/MMDD-主题名称/directory of the current Obsidian vault - Insert into Document - Insert
![[图片路径]]reference after each paragraph heading
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 obtain the style template.
Default to usingStyle 1 (minimal hand-drawn style), users 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 core idea of the paragraph, describe the diagram content in narrative language
- Chinese Labels - Write Chinese keywords directly (e.g., "data collection", "intelligent processing"), 1-3
- Chinese-dominant 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 (waiting for user confirmation):
## 提示词大纲
### 图 1: [段落标题]
- 图表类型: 概念图
- 提示词:
"""
[完整英文提示词]
"""
### 图 2: [段落标题]
...
Key:
- The main body of the prompt should be written in English, while text labels that need to appear in the image should retain the original Chinese text.
- Text labels that need to appear in the image should be written directly in the original Chinese (e.g.,
The central node labeled "AI生产力系统") - Each prompt must include the Chinese-dominant instruction at the end, ensuring the text in the image is primarily in Chinese, while professional terms may remain in English
4. Wait for Confirmation
After displaying all prompts, ask the user:
- "Are you satisfied with the above prompts? Do you need to modify the description of any image?"
- "Once confirmed, batch generation of images will begin ( N images in total)"
- Users may specify that a certain image uses a different style or modify the description
Phase 2 Detailed Guide
5. Use Codex built-in image2 to generate images
After confirmation, call Codex built-in image_gen tool one by one. Call it separately for each image; do not merge multiple different images into the same prompt.
Before tool invocation, organize each image prompt into a complete specification:
Use case: infographic-diagram
Asset type: Obsidian article illustration
Primary request: [完整提示词]
Aspect ratio: 16:9 landscape
Resolution intent: high resolution, suitable for article header/section illustration
Text policy: ALL text, labels, and annotations in the image MUST be primarily in Chinese (Simplified Chinese, 中文). Technical terms and abbreviations may remain in English.
Avoid: photography, realistic elements, complex gradients, watermark, illegible text
Notes:
- MMDD uses the current date (e.g., 0206)
- The topic name is extracted from the article's H1 title and simplified into a short name
- Image numbers are two digits (01, 02, 03...)
- After each image is generated, check whether the result meets: 16:9, consistent style, readable Chinese labels, no watermark
- If an image fails, record it and continue to the next one, then report the failed items at the end
- Codex built-in tools save images by default to
$CODEX_HOME/generated_images/...; the final images to be used by the project must be copied or moved into the Obsidian vault, and must not merely reference the default save location
6. Save path specification
/path/to/current/obsidian-vault/09 image/MMDD-主题简称/
├── 01-段落标题简称.png
├── 02-段落标题简称.png
├── 03-段落标题简称.png
└── ...
7. Insert into document
Insert the image reference below the corresponding paragraph heading in the article:
## 段落标题
![[09 image/MMDD-主题简称/01-段落标题简称.png]]
段落正文内容...
Use the Obsidian wikilink format ![[路径]] to insert.
Generation configuration
Codex built-in image2 (default)
| Configuration item | Value |
|---|---|
| Tool | Codex built-in image_gen |
| Model | Codex built-in image2 |
| API Key | No user input required |
| Default aspect ratio | 16:9 |
| Default resolution | High quality/project-ready |
Execution requirements:
- Use the
image_gentool to generate them one by one. - After generation, copy/move from
$CODEX_HOME/generated_images/...to the target filename. - When inserting an Obsidian wikilink, use a relative path within the vault, for example
![[09 image/MMDD-主题简称/01-段落标题简称.png]]。
CLI/API fallback (only when the user explicitly requests it)
scripts/generate_image.py Keep it as a legacy API fallback. Do not use it in the default workflow; call it only when the user explicitly requests LabNana, Gemini, CLI, API key, specified model parameters, or when the built-in image_gen is unavailable and the user confirms the fallback.
LabNana API fallback
| 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 |
Invocation example:
python3 scripts/generate_image.py \
--prompt "提示词内容" \
--output "/path/to/output.png" \
--provider labnana \
--aspect-ratio "16:9" \
--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 can choose a global style during the confirmation stage, or specify a different style for an individual image.
Common usage
| User says | Action |
|---|---|
| "Create a cover image for this article" | Generate 1 2.35:1 white-background engineering-style cover according to references/cover-style.md Generate 1 2.35:1 engineering-style cover with a white background |
| "Create a cover image, the title is xxx" | Generate 1 cover using the specified title and the article's logic |
| "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 editorial style |
| "Modify the prompt for the 3rd image" | Regenerate the specified image |
| "Regenerate the 2nd image" | Call the built-in image2 again with the modified prompt |