markdown-to-image
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkdown 转精美图片
Markdown to Exquisite Image
将 Markdown 内容渲染为精美的分享海报图片,适合微信、小红书、微博等平台。
Render Markdown content into beautiful shareable poster images, suitable for platforms like WeChat, Xiaohongshu, and Weibo.
核心特性
Core Features
- 固定 3:4 比例(1080×1440 像素)
- 自动分页 - 内容较多时生成多张图片
- 智能 SVG 头图 - 根据主题关键词自动生成相应风格的手绘线条图
- 智能标题 - 自动提取嘉宾名和主题,格式为「嘉宾:主题」
- 白色背景 + 大字体 - 清晰易读,专业排版
- 自适应布局 - 内容均匀分布,减少留白
- 宽字间距行间距 - 参考优秀海报排版
- Fixed 3:4 aspect ratio (1080×1440 pixels)
- Auto-pagination - Generate multiple images when content is extensive
- Smart SVG Header Image - Automatically generate hand-drawn line art in corresponding styles based on topic keywords
- Smart Title - Automatically extract guest names and topics in the format "Guest: Topic"
- White background + large font - Clear and readable, professional layout
- Adaptive layout - Evenly distribute content to reduce blank space
- Wide character and line spacing - Referencing excellent poster layouts
快速开始
Quick Start
基本用法
Basic Usage
bash
undefinedbash
undefined转换 Markdown 文件为图片(自动分页)
Convert Markdown file to images (auto-paginated)
python3 scripts/md_to_image.py --file /path/to/content.md
python3 scripts/md_to_image.py --file /path/to/content.md
指定输出目录
Specify output directory
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 --output-dir /path/to/output
调整每页条目数
Adjust number of items per page
python3 scripts/md_to_image.py --file /path/to/content.md --items-per-page 4
undefinedpython3 scripts/md_to_image.py --file /path/to/content.md --items-per-page 4
undefined参数说明
Parameter Description
| 参数 | 说明 | 默认值 |
|---|---|---|
| Markdown 文件路径 | 必填 |
| 输出目录 | |
| 图片宽度(像素) | |
| 每页显示条目数 | |
| Parameter | Description | Default Value |
|---|---|---|
| Path to Markdown file | Required |
| Output directory | |
| Image width (pixels) | |
| Number of items displayed per page | |
输出规格
Output Specifications
- 比例: 固定 3:4(1080×1440 像素)
- 格式: PNG
- 分页: 自动根据内容生成多张图片
- 命名: ,
page_1.png, ...page_2.png - 保存位置: 默认 (MMDD 为当日日期)
attachments/MMDD
- Aspect Ratio: Fixed 3:4 (1080×1440 pixels)
- Format: PNG
- Pagination: Automatically generate multiple images based on content
- Naming: ,
page_1.png, ...page_2.png - Save Location: Default (MMDD is the current date)
attachments/MMDD
智能 SVG 头图
Smart SVG Header Image
根据文章主题自动生成不同风格的 SVG 装饰图:
| 主题关键词 | 生成的 SVG 风格 |
|---|---|
| 神经网络节点 → 大脑 → 对话泡泡 |
| 开源符号 → 代码括号 → 分享图标 |
| 其他(默认) | 麦克风 → 声波 → 人物对话 |
SVG 特点:
- 手绘风格,黑色线条白底
- 宽幅 16:9 比例
- 140px 高度,居中显示
- 底部带主题文字标签
Automatically generate different styles of SVG decorative images based on article topics:
| Topic Keywords | Generated SVG Style |
|---|---|
| Neural network nodes → Brain → Dialogue bubbles |
| Open source symbols → Code brackets → Share icons |
| Others (Default) | Microphone → Sound waves → Character dialogue |
SVG Features:
- Hand-drawn style, black lines on white background
- Wide 16:9 aspect ratio
- 140px height, centered display
- With topic text label at the bottom
智能标题提取
Smart Title Extraction
自动从 Markdown 元信息中提取嘉宾和主题:
输入格式:
markdown
undefinedAutomatically extract guests and topics from Markdown meta-information:
Input Format:
markdown
undefined播客名称
Podcast Name
嘉宾: Sebastian Raschka(LLM研究员) 主题: 2025年AI技术趋势
**输出标题**:`Sebastian Raschka:2025年AI技术趋势`Guest: Sebastian Raschka (LLM Researcher) Topic: AI Technology Trends in 2025
**Output Title**: `Sebastian Raschka: AI Technology Trends in 2025`Markdown 格式处理
Markdown Format Processing
| 格式 | 渲染效果 |
|---|---|
| 自动提取并组合为「嘉宾:主题」 |
| 提取嘉宾名(移除 |
| 提取主题内容 |
| 红色加粗文字(移除 |
| 红色圆形数字编号 |
| 蓝色高亮引用 |
| Format | Rendering Effect |
|---|---|
| Automatically extracted and combined into "Guest: Topic" format |
| Extract guest name (remove |
| Extract topic content |
| Red bold text (remove |
| Red circular numbering |
| Blue highlighted quote |
工作流程
Workflow
当用户请求将 Markdown 转为图片时:
-
确定输入内容
- 如果用户指定了文件路径,使用该文件
- 如果用户当前打开了 Markdown 文件,默认使用该文件
-
自动处理
- 提取嘉宾和主题生成标题
- 根据主题关键词生成相应 SVG 头图
- 提取短版摘要(部分)
📱 短版摘要 - 移除所有 markdown 标记,转为真正的加粗样式
** - 根据条目数量自动分页
-
输出结果
- 返回所有图片路径给用户
- 图片保存在 目录
attachments/MMDD
When a user requests to convert Markdown to images:
-
Determine Input Content
- If the user specifies a file path, use that file
- If the user has a Markdown file open, use that file by default
-
Automatic Processing
- Extract guest and topic to generate title
- Generate corresponding SVG header image based on topic keywords
- Extract short summary (section marked )
📱 Short Summary - Remove all markdown markers and convert to actual bold style
** - Automatically paginate based on number of items
-
Output Results
- Return all image paths to the user
- Images are saved in the directory
attachments/MMDD
常见用法
Common Usage
| 用户说 | 操作 |
|---|---|
| 「把这个转成图片」 | 转换当前打开的 Markdown 文件 |
| 「生成分享海报」 | 同上 |
| 「这个播客摘要转图片」 | 转换播客摘要文件 |
| 「Markdown 转图片」 | 同上 |
| User Input | Action |
|---|---|
| 「把这个转成图片」 | Convert the currently open Markdown file |
| 「生成分享海报」 | Same as above |
| 「这个播客摘要转图片」 | Convert the podcast summary file |
| 「Markdown 转图片」 | Same as above |
依赖
Dependencies
脚本依赖以下 Python 包:
- - 浏览器自动化渲染
playwright - - Markdown 解析
markdown - - 网络请求(备用)
requests
首次使用需安装:
bash
pip3 install playwright markdown requests
playwright install chromiumThe script depends on the following Python packages:
- - Browser automation rendering
playwright - - Markdown parsing
markdown - - Network requests (backup)
requests
Install for first use:
bash
pip3 install playwright markdown requests
playwright install chromium更新日志
Changelog
v1.1 (2026-02-01)
v1.1 (2026-02-01)
- ✅ 智能 SVG 头图:根据主题关键词自动生成相应风格
- ✅ 智能标题:自动提取「嘉宾:主题」格式
- ✅ 移除 标记:元信息和正文中的 markdown 加粗正确转换
** - ✅ SVG 更大更醒目:140px 高度,600px 宽
- ✅ 优化排版:更大字体、更宽间距、自适应布局
- ✅ Smart SVG Header Image: Automatically generate corresponding styles based on topic keywords
- ✅ Smart Title: Automatically extract in "Guest: Topic" format
- ✅ Remove markers: Correctly convert markdown bold in meta-information and body content
** - ✅ Larger and more prominent SVG: 140px height, 600px width
- ✅ Optimized layout: Larger font, wider spacing, adaptive layout
v1.0 (2026-02-01)
v1.0 (2026-02-01)
- 初始版本
- 固定 3:4 比例
- 自动分页
- 白色背景设计
- Initial version
- Fixed 3:4 aspect ratio
- Auto-pagination
- White background design