Skip to content

This project extends node-html-to-image using the sharp library to allow users to specify the zoom factor and dpi of the generated images.

License

Notifications You must be signed in to change notification settings

rlongdragon/htmlToImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using sharp.js in conjunction with the node-html-to-image library allows specifying the enlargement factor and DPI for generating images.

English README | 中文文檔

Getting Started

This project relies on node.js.

You need to download the sharp and node-html-to-image libraries first.

npm install sharp
npm install node-html-to-image

Copy index.js and index.html to your project folder.

You can design your image within the <body> of index.html and generate your image using index.js.

Parameter Explanation

To generate an image, you need to execute the htmlToImage(data) function in index.js.

let data = {
  html: require('fs').readFileSync('./index.html', 'utf8'),
  fileName: 'image.png',
  width: 100,
  height: 100,
  scale: 1,
  dpi: 100
}
Parameter Description Type
html HTML format, imported from index.html string
fileName Filename for the generated image string
width Width of the image number
height Height of the image number
scale Image scaling factor number
dpi DPI setting for the image number

About

This project extends node-html-to-image using the sharp library to allow users to specify the zoom factor and dpi of the generated images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published