← 返回
内容创作 中文

LH HTML to Image

Convert HTML+CSS into PNG images via Chrome headless for accurate text layouts like covers, posters, and info cards at zero API cost.
将 HTML+CSS 通过 Chrome headless 转为 PNG,精准呈现封面、海报、信息卡等文字布局,零 API 费用。
liuhedev
内容创作 clawhub v1.0.1 1 版本 99895.8 Key: 无需
★ 1
Stars
📥 939
下载
💾 60
安装
1
版本
#latest

概述

HTML to Image

Generate images from HTML+CSS using Chrome headless screenshots. Ideal for covers, posters, info cards, and any text-heavy visual content. Zero API cost, 100% accurate text rendering.

Use Cases

  • ✅ Cover images (title + subtitle + tags)
  • ✅ Info cards (data display, comparison charts)
  • ✅ Text layout images (quote cards, highlight cards)
  • ❌ Illustrations, photos (use an AI image generation tool)

Workflow

Step 1: Write HTML

Create an HTML file with inline CSS:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
  body {
    width: 1080px;
    height: 1440px;   /* 3:4 portrait */
    margin: 0;
    overflow: hidden;
    font-family: -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  }
</style>
</head>
<body>
  <!-- Your content here -->
</body>
</html>

Step 2: Chrome Headless Screenshot

# macOS
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --headless=new \
  --disable-gpu \
  --screenshot="output.png" \
  --window-size=1080,1440 \
  --hide-scrollbars \
  --force-device-scale-factor=2 \
  "file:///absolute/path/to/your.html"

# Linux (auto-detect chrome/chromium)
google-chrome --headless=new --disable-gpu \
  --screenshot="output.png" \
  --window-size=1080,1440 \
  --hide-scrollbars \
  "file:///absolute/path/to/your.html"

Chrome path can be overridden via CHROME_PATH environment variable.

Common Sizes

PurposeWidth×HeightRatio
-----------------------------
Portrait cover1080×14403:4
Square cover1080×10801:1
Widescreen cover1920×108016:9
Social media banner1280×72016:9

Tips

  • Chrome GPU error logs can be safely ignored
  • Use --force-device-scale-factor=2 for retina/high-DPI output (doubles pixel dimensions)
  • Use --force-device-scale-factor=1 for exact pixel dimensions
  • CJK fonts: PingFang SC (macOS built-in), Noto Sans SC (Linux, install via apt install fonts-noto-cjk)
  • For complex layouts, test in a regular browser first, then screenshot

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-30 07:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

Humanizer

biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 860 📥 200,074
productivity

LH Edge TTS

liuhedev
使用 Python edge‑tts 将文本转为语音,支持多种语音、语言、语速调节、音调控制以及子...
★ 0 📥 1,597
content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,232