npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

web-to-png

v1.0.1

Published

使用 Node.js + Puppeteer 将 HTML 文件或 URL 转换为图片,支持长图(整页)截图。

Readme

web-to-png

使用 Node.js + Puppeteer 将 HTML 文件或 URL 转换为图片,支持长图(整页)截图。

安装

  • 需要已安装 Node.js(建议 18+)。
  • 已在项目中添加 Puppeteer 依赖,首次安装会自动下载 Chromium。

使用

  1. 将本地 HTML 转成 PNG(默认长图)
npm run web-to-image -- samples/long.html --output samples/long.png
  1. 将在线 URL 转成 JPEG(质量 90)
npm run web-to-image -- https://example.com --type jpeg --quality 90 --output out.jpg
  1. 自定义视口大小并关闭长图(仅当前视口)
npm run web-to-image -- samples/long.html --width 1440 --height 900 --no-full --output viewport.png

CLI 参数

  • input:必填,本地 HTML 文件路径或 http(s):///file:// URL。
  • --output, -o:输出图片路径,默认 output.png
  • --type, -t:图片类型 png|jpeg,默认 png
  • --width, -w:页面视口宽度,默认 1280
  • --height, -h:页面视口高度,默认 800
  • --quality, -q:JPEG 质量 0-100,默认 80(仅对 jpeg 生效)。
  • --wait:加载后额外等待毫秒数(处理异步渲染场景)。
  • --no-full:关闭整页截图,改为仅当前视口截图。

说明

  • 对于本地 HTML,脚本会自动使用 file:// 协议加载,无需本地服务器。
  • 默认使用整页截图(长图),适合需要完整页面内容的场景。
  • 如页面包含异步内容,可通过 --wait 传入等待时间确保内容渲染完成。