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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-html-2-image

v1.0.3

Published

A node.js command line utility that generates images from html provided as URL or local file

Downloads

26

Readme

Description

A node.js command line utility that generates an image (png, jpeg or webp) from html file or URL with the help of puppeteer.

Install

npm install -g node-html-2-image

Usage

Generate an image from URL:

html2image --url=https://www.google.com --dest=google.png --type=png

Generate an image from local file:

html2image --src=my-site.html --dest=my-site.jpg --type=jpeg

Generate an image from local file but run it in a local server (many times local html files will not load Javascript so they need to be run from a local server):

html2image --src=my-site.html --local-server --dest=my-site.jpg --type=jpeg

NOTE: The shell commands must not be run under root. Chromium doesn't allow it.

Options

List of all available options:

| option | description | type | default | required | |----------------|--------------------------------------------------------------------------------|---------------------------|---------|----------------------------| | url | The URL to use for the image generation | string | N/A | required if src is empty | | src | The path to the HTML file | string | N/A | required if url is empty | | dest | The destionation path and filename where to save the generated image | string | N/A | required | | type | The type of the generated image | png | jpeg | webp | png | required | | quality | The quality of the generated image (only applicable for jpeg) | number | 80 | optional | | width | The puppeteer page width in pixels | number | 800 | optional | | height | The puppeteer page height in pixels | number | 600 | optional | | slow-motion | The milliseconds of delay between the steps in loading the page in puppeteer | number | 0 | optional | | delay | The milliseconds to wait after the page is loaded and the screenshot is taken | number | 1000 | optional | | cookie-name | A cookie name to send when requesting the url | string | NULL | optional | | cookie-value | A cookie name to send when requesting the url | string | NULL | optional | | local-server | Whether to load the src html in a local server | boolean | false | optional | | port | The port for the local server | number | 3000 | optional | | debug | Whether to print debug information from the loaded page to the stdout | number | 600 | optional |

NOTE: src can be pointing to directory or file. If it is a directory, then there must be index.html file inside of it.