技能圖譜SKILLSGROVE
技能圖譜/效率工具/shiker1996/wechat-editroom/html-pages-to-images

html-pages-to-images

安裝

$npx skills add https://github.com/shiker1996/wechat-editroom --skill html-pages-to-images
$git clone --depth 1 https://github.com/shiker1996/wechat-editroom.git /tmp/wechat-editroom && mkdir -p ~/.claude/skills && cp -r /tmp/wechat-editroom/skills/html-pages-to-images ~/.claude/skills/html-pages-to-images
請幫我安裝這個 Agent Skill:https://github.com/shiker1996/wechat-editroom/tree/c64599cd038ab7f5251ba03c14fad72d3edf3951/skills/html-pages-to-images ,先閱讀它的 SKILL.md 和指令碼,確認安全後再安裝到我的技能目錄。

簡介

原文描述 · MIT使用本地 Chromium/Puppeteer 将可信 HTML 文件中匹配 CSS 选择器的多个元素逐一截图为 PNG。适用于图表、卡片、页面或公众号内联模块批量转图,并由 wechat-echarts-blocks-to-images 间接调用。不上传图片、不改写 Markdown,不应渲染不可信 HTML。
以下 SKILL.md 內容轉載自 shiker1996/wechat-editroom(提交 c64599c),依據 MIT 許可證轉載正文(文字未改動;僅省略檔案頭後設資料、將圖片顯示為連結,超長內容會截斷);版權歸 2026 shiker 所有。許可證:LICENSE。僅展示說明檔案,附帶指令碼請在原倉庫檢視。

HTML 元素批量截图

只渲染来自当前任务或可信模板的本地 HTML。HTML 可执行脚本并加载远程资源,不要对未知来源文件使用本技能。

执行

node index.js --htmlFile <input.html> --outputDir <output-dir> --selector <css-selector> --pageWidth 375 --pageHeight 667 --deviceScaleFactor 3

所有路径应显式传入,不依赖目录内的示例文件或默认 output。输出目录应位于当前任务工作目录,避免不同文章互相覆盖。

参数

  • htmlFile:必填,本地 HTML
  • outputDir:必填,PNG 输出目录
  • selector:必填,只截图匹配元素
  • pageWidth/pageHeight:CSS 视口尺寸
  • deviceScaleFactor:默认 2–3,控制清晰度与内存

门禁

截图前确认选择器至少匹配一个元素。完成后确认图片数量等于匹配数、每个 PNG 非空、文件名唯一且输出尺寸合理。若字体、图表或远程资源未加载完成,等待明确的完成标志;超时则失败,不输出空白图冒充成功。

该技能只返回本地图片路径;公网化必须由单独上传技能在用户授权后执行。

檢視許可證全文(MIT)
MIT License

Copyright (c) 2026 shiker

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.