Weixin Long Image
Use this skill to turn rich HTML layouts into long PNGs for Weixin delivery.
Core Rule
In Weixin direct chats, if the reply body for the user would exceed 150 Chinese characters, treat this as a hard rule: prefer this skill over a long plain-text message.
When To Use
Use this skill when any of these is true:
- - The Weixin reply would be long and hard to read as plain chat text.
- The user asks for a card, poster, beautiful layout, or visually polished output.
- The content needs HTML rendering power, such as:
- charts
- tables
- timelines
- curves / trend visuals
- relation diagrams
- dashboards
- mixed text + image layouts
- - You want stable final presentation rather than chat-native formatting.
Default Visual Standard
Unless the user explicitly wants a poster/card/dashboard style, default to a WeChat public-article layout, not a centered floating card.
Night Rule
In Asia/Shanghai time, if the image is being prepared at 22:00 or later, default to a dark-mode article template to reduce eye strain, unless the user explicitly asks for a light theme.
Default article layout
- - Use a plain white page background.
- Keep only moderate side margins for readability.
- Do not wrap the whole article in a large rounded card with heavy shadow.
- Prefer continuous reading flow, like a WeChat public account article.
- Use readable typography, generous line height, and responsive images.
Default dark article layout after 22:00
- - Use a dark page background with softened contrast.
- Keep the same article flow and margins as the daytime template.
- Avoid excessive glow, neon accents, or dashboard-style visuals unless explicitly requested.
- Preserve readability first: muted metadata, bright headings, comfortable code blocks, and responsive images.
Use card style only when appropriate
Reserve card/poster/dashboard styling for cases like:
- - cover cards
- poster-like announcements
- KPI / dashboard views
- side-by-side comparison blocks
- highly visual share cards
For ordinary long articles, analysis notes, translated writeups, and image-heavy explanations, prefer article layout.
Reusable Templates
Use assets/wechat-article-template.html as the default starting point for daytime article-style pages.
Use assets/wechat-article-template-dark.html as the default starting point for article-style pages prepared at or after 22:00 Asia/Shanghai.
They provide:
- - WeChat-like article spacing
- narrower side margins
- no outer card shell
- responsive images
- readable tables
- wrapped code blocks
- simple note/tip blocks
- matched light/dark article styles
Workflow
- 1. Write a complete HTML document first.
- For article-like content, choose the template by time:
- before 22:00 Asia/Shanghai →
assets/wechat-article-template.html
- at or after 22:00 Asia/Shanghai →
assets/wechat-article-template-dark.html
- 3. Render the HTML with
scripts/render_long_image.py. - Send the PNG with the
message tool using an absolute local path. - After the
message send succeeds, immediately delete temporary render artifacts (.png and temporary .html) unless the user explicitly asked to keep them. - In Weixin direct chats, use
message for any progress update; do not rely on multi-part assistant text arriving in order.
Quick Start
CODEBLOCK0
You may also pass raw HTML via --input or stdin.
Input Rules
- - The script accepts complete HTML only.
- INLINECODE11 can be a file path or inline HTML.
- If
--input is omitted, read HTML from stdin. - INLINECODE13 is optional.
- If provided, persist the rendered HTML there.
- If omitted and
--input is an existing HTML file, reuse that file.
- If omitted and the source is inline HTML or stdin, create a temporary HTML file and auto-delete it after rendering.
- - If the source content starts as text, convert it into HTML first.
Rendering Guidance
- - Build for phone reading first.
- For long-form articles, prefer article layout over card layout.
- For tables, charts, diagrams, and mixed media, define layout explicitly in CSS instead of relying on browser defaults.
- If images are embedded in the HTML, make them responsive with
max-width: 100% unless overflow is intentional. - Use absolute output paths so the PNG can be delivered reliably.
- If the content is sensitive, write outputs inside the workspace or
/tmp, send the PNG, then remove temporary files if appropriate.
Sending
Use message with the generated PNG path.
- - INLINECODE18
- INLINECODE19
- INLINECODE20
- INLINECODE21
Post-send cleanup
For temporary outputs, once message reports success, delete the local render artifacts immediately.
Typical cleanup:
CODEBLOCK1
Rules:
- - Prefer writing temporary outputs under
/tmp. - Delete the PNG after a successful send unless the user asked to keep the file.
- Delete the HTML too when it is only an intermediate artifact.
- If
render_long_image.py used inline HTML or stdin without --html-out, the script already auto-deletes its temporary HTML file; you still need to delete the PNG after send.
After a user-visible message send, reply with NO_REPLY to avoid duplicates.
Troubleshooting
- - If Playwright cannot launch Chromium, verify the local Playwright browser runtime is installed.
- If the screenshot looks clipped, increase
--width or fix the HTML/CSS layout first. - If the result is too tall, split the content into multiple HTML pages and render multiple images.
- If the content is short and visually simple, skip this skill and reply normally.
Assets
- -
assets/wechat-article-template.html: Default daytime HTML template for WeChat-article-style long images. - INLINECODE30 : Default night-mode HTML template for WeChat-article-style long images after 22:00 Asia/Shanghai.
Script
- -
scripts/render_long_image.py: Render complete HTML into a long PNG screenshot.
微信长图
使用此技能将富HTML布局转换为用于微信发送的长PNG图片。
核心规则
在微信直接对话中,如果对用户的回复正文超过150个中文字符,将此视为硬性规则:优先使用此技能而非发送长文本消息。
使用时机
当以下任一情况成立时使用此技能:
- - 微信回复内容较长,作为纯聊天文本难以阅读
- 用户要求卡片、海报、精美布局或视觉上精致的输出
- 内容需要HTML渲染能力,例如:
- 图表
- 表格
- 时间线
- 曲线/趋势可视化
- 关系图
- 仪表盘
- 图文混合布局
- - 您希望获得稳定的最终呈现效果,而非依赖聊天原生格式
默认视觉标准
除非用户明确要求海报/卡片/仪表盘风格,否则默认使用微信公众号文章布局,而非居中浮动的卡片样式。
夜间规则
在亚洲/上海时区,如果图片准备时间在22:00或之后,默认使用深色模式文章模板以减少视觉疲劳,除非用户明确要求浅色主题。
默认文章布局
- - 使用纯白色页面背景
- 仅保留适度的侧边距以保证可读性
- 不要将整篇文章包裹在带有厚重阴影的大圆角卡片中
- 采用连续阅读流,类似微信公众号文章
- 使用可读性好的排版、宽松的行高和响应式图片
22:00后默认深色文章布局
- - 使用深色页面背景,对比度柔和
- 保持与日间模板相同的文章流和边距
- 避免过度使用发光、霓虹效果或仪表盘风格的可视化,除非用户明确要求
- 优先保证可读性:柔和的元数据、明亮的标题、舒适的代码块和响应式图片
仅在适当时使用卡片样式
将卡片/海报/仪表盘样式保留用于以下情况:
- - 封面卡片
- 海报式公告
- KPI/仪表盘视图
- 并排对比区块
- 高度视觉化的分享卡片
对于普通长文、分析笔记、翻译文稿和图片丰富的说明,优先使用文章布局。
可复用模板
使用assets/wechat-article-template.html作为日间文章风格页面的默认起点。
使用assets/wechat-article-template-dark.html作为亚洲/上海时区22:00或之后准备的文章风格页面的默认起点。
它们提供:
- - 类似微信的文章间距
- 较窄的侧边距
- 无外部卡片外壳
- 响应式图片
- 可读性好的表格
- 包裹的代码块
- 简单的注释/提示块
- 匹配的浅色/深色文章样式
工作流程
- 1. 首先编写完整的HTML文档
- 对于文章类内容,根据时间选择模板:
- 亚洲/上海时区22:00前 → assets/wechat-article-template.html
- 亚洲/上海时区22:00及之后 → assets/wechat-article-template-dark.html
- 3. 使用scripts/renderlongimage.py渲染HTML
- 使用message工具发送PNG图片,使用绝对本地路径
- 在message发送成功后,立即删除临时渲染产物(.png和临时.html),除非用户明确要求保留
- 在微信直接对话中,使用message进行任何进度更新;不要依赖多部分助手文本按顺序到达
快速开始
bash
python3 scripts/renderlongimage.py \
--input /absolute/path/to/page.html \
--png-out /absolute/path/to/output.png
您也可以通过--input或标准输入传递原始HTML。
输入规则
- - 脚本仅接受完整的HTML
- --input可以是文件路径或内联HTML
- 如果省略--input,则从标准输入读取HTML
- --html-out为可选参数
- 如果提供,将渲染后的HTML保存到该路径
- 如果省略且--input是现有的HTML文件,则复用该文件
- 如果省略且源内容是内联HTML或标准输入,则创建临时HTML文件并在渲染后自动删除
渲染指南
- - 首先为手机阅读构建
- 对于长篇文章,优先使用文章布局而非卡片布局
- 对于表格、图表、图示和混合媒体,在CSS中明确定义布局,而非依赖浏览器默认设置
- 如果HTML中嵌入了图片,使用max-width: 100%使其响应式,除非有意溢出
- 使用绝对输出路径,以便可靠地传递PNG
- 如果内容敏感,在工作区或/tmp内写入输出,发送PNG,然后酌情删除临时文件
发送
使用message工具,传入生成的PNG路径。
- - action=send
- channel=openclaw-weixin
- media=/absolute/path/to/output.png
- message=一句很短的说明
发送后清理
对于临时输出,一旦message报告成功,立即删除本地渲染产物。
典型清理:
bash
rm -f /absolute/path/to/output.png /absolute/path/to/output.html
规则:
- - 优先将临时输出写入/tmp下
- 成功发送后删除PNG,除非用户要求保留文件
- 当HTML仅为中间产物时也删除它
- 如果renderlongimage.py使用了内联HTML或标准输入且未指定--html-out,脚本已自动删除其临时HTML文件;您仍需要在发送后删除PNG
在用户可见的message发送后,回复NO_REPLY以避免重复。
故障排除
- - 如果Playwright无法启动Chromium,请验证本地Playwright浏览器运行时已安装
- 如果截图被裁剪,先增加--width或修复HTML/CSS布局
- 如果结果过长,将内容拆分为多个HTML页面并渲染多张图片
- 如果内容简短且视觉简单,跳过此技能并正常回复
资源文件
- - assets/wechat-article-template.html:微信公众号文章风格长图的默认日间HTML模板
- assets/wechat-article-template-dark.html:亚洲/上海时区22:00后微信公众号文章风格长图的默认夜间HTML模板
脚本
- - scripts/renderlongimage.py:将完整HTML渲染为长PNG截图