html-to-image-render
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "html-to-image-render" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-57b03c05959399637f5a89eb83ab6ffe3c8b8b2ed9fd30e4b2016c864b3f39bd. Verify the upstream source and version against https://skillhub.cn/skills/user_d8831e99/html-to-image-render before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Use when you need to render HTML files to images. Functions include reading an HTML file, performing the rendering, and saving the generated image to a local file.
Introduction source: third_party · user_d8831e99 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Limits and differences
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: html-to-image-render
slug: html-to-image-render
displayName: HTML渲染为图片
description: 当需要把 HTML 文件渲染成图片时使用,包括读取 HTML 文件、执行渲染,并将生成的图片保存到本地文件。
version: 1.0.0
author: AtomCode
tags: [HTML, 渲染, 图片, 工具]HTML 转图片
当任务是把本地 .html 文件通过远端 html2image API 渲染成图片时,使用这个 skill。
工作流
- 从磁盘读取 HTML 文件内容。
- 如有必要,先查看
references/html-to-image-api.md中的接口约定。 - 运行
scripts/render-html-to-image.ts,传入输入 HTML 路径和输出图片路径。 - 确认生成的图片文件已经落到目标位置。
脚本说明
内置脚本会完成这些事情:
- 以 UTF-8 读取 HTML 文件
- 调用
POST https://html2image.hanfangyuan.cn/api/html2image - 解码返回的
image_base64 - 把图片写入本地磁盘
示例:
npx -y tsx skills/html-to-image-render/scripts/render-html-to-image.ts \
--input ./demo/card.html \
--output ./out/card.png \
--element-id card \
--image-type png
执行这个脚本依赖本机可用的 npx,并通过 npx -y tsx 临时执行 TypeScript 文件。首次运行时通常会下载 tsx。
参数说明
必选参数
--input:输入的本地 HTML 文件路径。--output:输出图片文件路径。
可选参数
--element-id:要截图的元素 id,传原始 id 值,不要带#。--image-type:支持png和jpeg。--device-scale-factor:设备像素比,越大越清晰,但图片通常也更大。--viewport-width/--viewport-height:渲染视口尺寸。--render-wait-ms:截图前额外等待时间,适合等待字体、图片等异步资源。--element-padding:当指定--element-id时,为截图区域额外增加的边距,默认值为0。
注意事项
- 运行环境需要可用的
npx。 - 如果 HTML 中使用图片资源,需要使用公网可访问的图片链接,不支持本地图片路径。
- 输出文件扩展名应与
--image-type保持一致。 - 要注意实际截图区域的尺寸是否能完整容纳目标 HTML。尤其当卡片宽高大于默认视口时,必须显式调整
--viewport-width和--viewport-height,避免截图被裁切或图片不完整。 - 只有在默认渲染结果不满足需求时,再调整视口和等待时间参数;但如果 HTML 的设计尺寸本身就大于默认视口,应该优先先把视口调到不小于目标元素尺寸。
- 如果接口返回
400,通常是element_id对应元素不存在。 - 如果接口返回
422,通常是参数范围不合法。
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 HTML 转图片的实用功能,适用于前端开发和自动化截图场景
Highlights
- 触发描述清晰明确,使用场景边界清晰
Highlights
- 文档结构完整,包含详细的工作流、参数说明和示例
Areas to improve
-
缺少基础异常处理说明 Reported severity: Minor
未提及网络异常、文件读写失败等基础异常的处理方式
Recommendation: 建议在注意事项中补充对网络连接失败、文件权限不足等常见异常的处理建议
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 34, 41, 61
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- html2image.hanfangyuan.cn
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.