Render Markdown content into beautiful share poster images, suitable for platforms such as WeChat, Xiaohongshu, and Weibo.
Core Features
- Fixed 3:4 ratio(1080×1440 pixels)
- Automatic pagination - Generates multiple images when there is a lot of content
- Smart SVG header image - Automatically generates hand-drawn line art in a corresponding style based on topic keywords
- Smart title - Automatically extracts the guest name and topic, in the format "Guest: Topic"
- White background + large fonts - Clear and easy to read, professional typography
- Adaptive layout - Content is evenly distributed, reducing whitespace
- Wide letter spacing and line spacing - References excellent poster typography
Quick Start
Basic Usage
# 转换 Markdown 文件为图片(自动分页)
python3 scripts/md_to_image.py --file /path/to/content.md
# 指定输出目录
python3 scripts/md_to_image.py --file /path/to/content.md --output-dir /path/to/output
# 调整每页条目数
python3 scripts/md_to_image.py --file /path/to/content.md --items-per-page 4
Parameter Description
| Parameter | Description | Default Value |
|---|---|---|
--file, -f |
Markdown file path | Required |
--output-dir, -o |
Output directory | attachments/MMDD |
--width, -w |
Image width (pixels) | 1080 |
--items-per-page |
Number of items displayed per page | 5 |
Output Specifications
- Ratio: Fixed 3:4 (1080×1440 pixels)
- Format: PNG
- Pagination: Automatically generates multiple images based on content
- Naming:
page_1.png,page_2.png, ... - Save location: Default
attachments/MMDD(MMDD is the current date)
Smart SVG Header Image
Automatically generates SVG decorative images in different styles based on the article topic:
| Topic Keywords | Generated SVG Style |
|---|---|
AI、AGI、通用 |
Neural network nodes → Brain → Speech bubbles |
开源、open source |
Open source symbols → Code brackets → Share icon |
| Other (default) | Microphone → Sound waves → People talking |
SVG Features:
- Hand-drawn style, black lines on a white background
- Wide 16:9 ratio
- 140px height, centered display
- Bottom with topic text label
Smart Title Extraction
Automatically extracts the guest and topic from Markdown metadata:
Input Format:
# 播客名称
> **嘉宾**: Sebastian Raschka(LLM研究员)
> **主题**: 2025年AI技术趋势
Output Title:Sebastian Raschka:2025年AI技术趋势
Markdown Format Handling
| Format | Rendering Effect |
|---|---|
# 标题 |
Automatically extracts and combines into "Guest: Topic" |
> **嘉宾**: ... |
Extracts guest name (removes **) |
> **主题**: ... |
Extracts topic content |
**加粗** |
Red bold text (removes ** markers) |
1、2、3、 |
Red circular number numbering |
"引用内容" |
Blue highlighted quote |
Workflow
When the user requests to convert Markdown to an image:
-
Determine the input content
- If the user specifies a file path, use that file
- If the user currently has a Markdown file open, use that file by default
-
Automatic processing
- Extract guests and topics to generate the title
- Generate a corresponding SVG header image based on topic keywords
- Extract the short version summary (
📱 短版摘要section) - Remove all
**markdown markup and convert to true bold styling - Automatically paginate based on the number of items
-
Output results
- Return all image paths to the user
- Images are saved in the
attachments/MMDDdirectory
Common usage
| User says | Action |
|---|---|
| "Convert this to an image" | Convert the currently open Markdown file |
| "Generate a share poster" | Same as above |
| "Convert this podcast summary to an image" | Convert the podcast summary file |
| "Markdown to image" | Same as above |
Dependencies
The script depends on the following Python packages:
playwright- Browser automation renderingmarkdown- Markdown parsingrequests- Network requests (fallback)
Install on first use:
pip3 install playwright markdown requests
playwright install chromium
Changelog
v1.1 (2026-02-01)
- ✅ Smart SVG header image: automatically generates the corresponding style based on topic keywords
- ✅ Smart title: automatically extracts the "Guest: Topic" format
- ✅ Remove
**markup: markdown bold in metadata and body text is correctly converted - ✅ Larger and more prominent SVG: 140px height, 600px width
- ✅ Optimized layout: larger fonts, wider spacing, responsive layout
v1.0 (2026-02-01)
- Initial version
- Fixed 3:4 ratio
- Automatic pagination
- White background design