Image-Text Posting (图文发表)
Post image-text messages with multiple images to WeChat Official Account.
Usage
# Post with images and markdown file (title/content extracted automatically)
npx -y bun ./scripts/wechat-browser.ts --markdown source.md --images ./images/
# Post with explicit title and content
npx -y bun ./scripts/wechat-browser.ts --title "标题" --content "内容" --image img1.png --image img2.png
# Save as draft
npx -y bun ./scripts/wechat-browser.ts --markdown source.md --images ./images/ --submitParameters
--markdown <path>
Markdown file for title/content extraction
--images <dir>
Directory containing images (sorted by name)
--title <text>
Article title (max 20 chars, auto-compressed if too long)
--content <text>
Article content (max 1000 chars, auto-compressed if too long)
--image <path>
Single image file (can be repeated)
--submit
Save as draft (default: preview only)
--profile <dir>
Chrome profile directory
Auto Title/Content from Markdown
When using --markdown, the script:
Parses frontmatter for title and author:
Falls back to H1 if no frontmatter title:
Compresses title to 20 characters if too long:
Original: "如何在一天内彻底重塑你的人生"
Compressed: "一天彻底重塑你的人生"
Extracts first paragraphs as content (max 1000 chars)
Image Directory Mode
When using --images <dir>:
All PNG/JPG files in directory are uploaded
Files are sorted alphabetically by name
Naming convention:
01-cover.png,02-content.png, etc.
Constraints
Title
20 chars
Auto-compressed if longer
Content
1000 chars
Auto-compressed if longer
Images
9 max
WeChat limit
Example Session
Scripts
wechat-browser.ts
Main image-text posting script
cdp.ts
Chrome DevTools Protocol utilities
copy-to-clipboard.ts
Clipboard operations
Last updated