auto-md2img
by @fried-avocado
Convert Markdown content to images automatically with GitHub styling, full Chinese support, smart pagination, emoji support, and syntax highlighting. Support...
clawhub install auto-md2imgπ About This Skill
name: auto-md2img emoji: πΌοΈ description: Convert Markdown content to images automatically with GitHub styling, full Chinese support, smart pagination, emoji support, and syntax highlighting. Supports height-based pagination and JPEG quality adjustment. author: OpenClaw Community version: 1.3.1 license: MIT tags: ["markdown", "image", "convert", "md2img", "puppeteer", "pagination", "quality", "chinese"]
π₯ Auto MD2IMG Skill
Automatically converts Markdown content to images for sending in any messaging platform, improving reading experience.
β¨ Features
π Usage
When you need to reply to users with Markdown formatted content:
Basic Usage
1. Save Markdown content to a temporary file (or pass string directly)
2. Call scripts/md_to_png.js to generate images
3. Send images to users using tags
4. Embed paths using corresponding image tags for different messaging platforms
5. Fall back to sending plain text Markdown if image generation fails
Script Invocation
# Basic usage
node scripts/md_to_png.js input.mdSpecify output directory
node scripts/md_to_png.js input.md ./outputCustom lines per page
node scripts/md_to_png.js input.md ./output 300Custom JPEG quality (1-100, default 80)
node scripts/md_to_png.js input.md ./output 300 75Height-based pagination (custom height threshold in pixels, e.g. 2000px)
node scripts/md_to_png.js input.md ./output --height 2000Disable pagination entirely (output single image)
node scripts/md_to_png.js input.md ./output --height 0Enable Debug mode (output detailed logs + save pagination content)
node scripts/md_to_png.js input.md ./output --debug
Parameter Description
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| inputFile | string | β
| - | Path to input Markdown file |
| outputDir | string | β | Current directory | Output image directory |
| maxLinesPerPage | number | β | 500 | Maximum lines per page (line-based pagination) |
| imageQuality | number | β | 80 | JPEG image quality (1-100) |
| --height | number | β | - | Height-based pagination threshold in pixels. β€0 disables pagination entirely (single output image). Overrides line-based pagination. |
| --debug | flag | β | - | Enable Debug mode, output detailed logs and save intermediate pagination content |
π§ Configuration
Font Configuration
Output Configuration
Pagination Configuration
--height parameter), independent of line count--height 0Debug Mode
When enabled with--debug flag:
π Script Paths
scripts/md_to_png.js - Main Markdown to image tool
scripts/md_to_png.js Functions:
π― Usage Examples
Example 1: Simple Conversion
import { exec } from 'child_process';
import path from 'path';const markdownContent = # Hello World\n\nThis is test content.;
// Save to temporary file
const tempFile = path.join('/tmp', 'temp.md');
fs.writeFileSync(tempFile, markdownContent);
// Call conversion script
exec(node scripts/md_to_png.js ${tempFile}, (error, stdout, stderr) => {
if (error) {
console.error('Conversion failed:', error);
return;
}
console.log('Conversion successful:', stdout);
});
Example 2: Usage in Chat Applications
// When needing to reply with Markdown content
async function replyWithMarkdown(content, outputDir) {
try {
// Call md2img conversion
const baseName = reply_${Date.now()};
const files = await convertMarkdown(content, outputDir, baseName);
// Send images using
tags
for (const file of files) {
await sendMessage(
);
}
} catch (error) {
// Fall back to plain text on failure
await sendMessage(content);
}
}
Example 3: Height-based Pagination
# Split by 2000px height, ideal for mobile viewing
node scripts/md_to_png.js long_article.md ./output --height 2000No pagination, output single long image
node scripts/md_to_png.js short_note.md ./output --height 0JPEG quality adjustment for faster sharing
node scripts/md_to_png.js report.md ./output 500 60 --height 1500
Example 4: Debug Mode
# Debug mode for troubleshooting conversion issues
node scripts/md_to_png.js problem_content.md ./output --debug
π Security Features
π Performance Metrics
| Metric | Value | |--------|-------| | First browser startup | ~260ms | | Small document conversion (200 words) | ~2.3s | | Medium document conversion (2KB) | ~2.6s | | Large document conversion (5KB) | ~3.6s | | Repeated conversion performance improvement | 4.5% (single) / 50-70% (batch) |
π¨ Rendering Effects
Supported Markdown elements:
π New in v1.3.1
π οΈ Tech Stack
π Trigger Scenarios
All reply scenarios that require outputting Markdown formatted content:
β οΈ Notes
1. First conversion requires browser startup, slightly slower
2. Recommend enabling skipCacheClear configuration for batch conversions
3. Large documents may be split into multiple pages
4. Image files occupy disk space, remember to clean up
Chinese Instructions (δΈζθ―΄ζ)
Usage
When you need to reply to users with Markdown formatted content: 1. First save Markdown content to a temporary file (or pass string directly) 2. Callscripts/md_to_png.js to generate images
3. Send images to users using ![]()
tags
4. Embed paths using corresponding image tags for different messaging platforms
5. Fall back to sending plain text Markdown if image generation failsScript Path
scripts/md_to_png.js - Markdown to image toolConfiguration
Auto MD2IMG Skill - Make Markdown replies more beautiful! π
π‘ Examples
When you need to reply to users with Markdown formatted content:
1. First save Markdown content to a temporary file (or pass string directly)
2. Call scripts/md_to_png.js to generate images
3. Send images to users using tags
4. Embed paths using corresponding image tags for different messaging platforms
5. Fall back to sending plain text Markdown if image generation fails
Script Path
scripts/md_to_png.js - Markdown to image toolConfiguration
Auto MD2IMG Skill - Make Markdown replies more beautiful! π
βοΈ Configuration
Auto MD2IMG Skill - Make Markdown replies more beautiful! π