1.0.3 • Published 1 year ago

node-html-2-image v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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:

optiondescriptiontypedefaultrequired
urlThe URL to use for the image generationstringN/Arequired if src is empty
srcThe path to the HTML filestringN/Arequired if url is empty
destThe destionation path and filename where to save the generated imagestringN/Arequired
typeThe type of the generated imagepng | jpeg | webppngrequired
qualityThe quality of the generated image (only applicable for jpeg)number80optional
widthThe puppeteer page width in pixelsnumber800optional
heightThe puppeteer page height in pixelsnumber600optional
slow-motionThe milliseconds of delay between the steps in loading the page in puppeteernumber0optional
delayThe milliseconds to wait after the page is loaded and the screenshot is takennumber1000optional
cookie-nameA cookie name to send when requesting the urlstringNULLoptional
cookie-valueA cookie name to send when requesting the urlstringNULLoptional
local-serverWhether to load the src html in a local serverbooleanfalseoptional
portThe port for the local servernumber3000optional
debugWhether to print debug information from the loaded page to the stdoutnumber600optional

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

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago