← 返回
未分类

md2img

This skill should be used when the user wants to convert a Markdown (.md) file into a high-DPI screenshot image optimized for iPhone display and WeChat Moments sharing. It renders Markdown with syntax highlighting and beautiful typography, then outputs PNG/JPEG at 3x Retina resolution (1170px physical width) that survives WeChat compression while staying crisp on all iPhone screens. Trigger phrases include 'md 转图片', 'Markdown 截图', '生成朋友圈图片', '渲染 md 为图', '截图分享', '做成图片发朋友圈', or any request to convert .md to image.
Johnnyxsu
未分类 community v1.0.0 1 版本 99159.7 Key: 无需
★ 0
Stars
📥 118
下载
💾 2
安装
1
版本
#latest

概述

md2img - Markdown to High-DPI iPhone / WeChat Image

Convert Markdown files into beautiful, print-quality screenshots optimized for:

  • iPhone Retina display (3x pixel density)
  • WeChat Moments sharing (survives WeChat compression, stays crisp)

Core Script

All rendering is done by scripts/md2img.js. It uses Playwright (Chromium)

to render Markdown as styled HTML, then takes a full-page screenshot at 3x

device scale factor.

Workflow

Step 1 - Ensure Environment

Check if the environment is set up. Run node --version to confirm Node.js 16+

is available. If scripts/node_modules does not exist, run setup:

cd ~/.workbuddy/skills/md2img/scripts
bash setup.sh

If node is missing, install it:

brew install node   # macOS

Step 2 - Basic Conversion

cd ~/.workbuddy/skills/md2img/scripts
node md2img.js /path/to/your-file.md

Output: /path/to/your-file.png (same directory as input by default)

Step 3 - Choose Format Based on Content

Content TypeRecommended Command
-----------------------------------
Text-heavy (docs, articles)node md2img.js input.md (PNG, default)
Mixed text + imagesnode md2img.js input.md -f jpeg -q 92
Dark theme preferencenode md2img.js input.md --theme dark
Multi-section to multiple imagesnode md2img.js input.md --multi

Step 4 - Advanced Options

-o <path>           Output file path
-w <px>             Logical CSS width (default: 390, iPhone 14 width)
-s <n>              Device scale factor (default: 3, = 1170px physical)
-f png|jpeg         Format (default: png)
-q <0-100>          JPEG quality (default: 92)
--theme light|dark  Color theme (default: light)
--padding <px>      Body padding (default: 28)
--font-size <px>    Base font size (default: 17)
--multi             Split into multiple images by H1 heading

Common Recipes

# Standard article -> WeChat-ready PNG
node md2img.js article.md

# Long technical doc -> JPEG (smaller file, less double-compression loss)
node md2img.js doc.md -f jpeg -q 92

# Dark theme screenshot
node md2img.js notes.md --theme dark -o notes-dark.png

# Split long post into 9 images for WeChat grid
node md2img.js long-post.md --multi

# Custom width for iPad-style layout
node md2img.js report.md -w 768 -s 2

# Larger font for easier reading
node md2img.js article.md --font-size 19

Resolution Rationale

Why 390px x 3 = 1170px physical?

  • iPhone 14/15 has 390px logical width, at 3x Retina = 1170px physical
  • WeChat Moments triggers heavy compression only above 2000px (long edge)
  • 1170px < 2000px, so WeChat applies only light compression (~85% quality)
  • Text remains sharp after WeChat compression because starting resolution is high

For detailed specs, see references/wechat_image_specs.md.

Troubleshooting

ProblemSolution
------------------
Cannot find module playwrightRun bash setup.sh in scripts/ dir
browserType.launch Executable does not existRun npx playwright install chromium
Chinese characters show as squaresInstall CJK fonts: brew install --cask font-noto-sans-cjk
Image too tall for WeChatUse --multi to split, or reduce --font-size
JPEG artifacts on textSwitch to PNG (default), or raise -q 95

Output Quality Guidelines

  • Minimum: -s 2 (780px) - acceptable for casual sharing
  • Recommended: -s 3 (1170px) - sharp on iPhone, survives WeChat
  • Maximum useful: -s 4 (1560px) - for printing or high-stakes sharing
  • Avoid: -s 6+ exceeds 2000px, triggers WeChat heavy compression

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-04-03 16:52 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,030
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 671 📥 324,378
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,816