Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-image-from-html

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-image-from-html

Convert HTML data into images, with a persistant headless browser!

  • 2.0.6
  • npm
  • Socket score

Version published
Weekly downloads
25
increased by1150%
Maintainers
1
Weekly downloads
 
Created
Source

node-image-from-html

Convert HTML data into images, with a persistant headless browser!

Features

  • Speed - Unlike most other libraries, this insures the headless browser stays alive, and wastes no time re-launching.

  • Concurrency - Allows for one browser to spawn multiple tabs, shifting the workload to them if one is active.

  • ID or Full-Page selection options.

  • Default Background Transparency.

  • Raw Base64 Output

Example

const ImageFromHtml = require("node-image-from-html");
const fs = require("fs");

(async () => {

    const Handler = new ImageFromHtml.BrowserHandler(1, { headless: true })

    await Handler.start()

    // Regardless of the position or the padding around the element, the screenshot will always be of the div in question. In this case, "entry".
    let base64 = await Handler.render(`<div id="entry" style="width:100px;height:100px;padding:300px;background-color:blue"></div>`, "entry")

    fs.writeFileSync("myImage.png", base64, {encoding: "base64"})

})()

Efficiency?

This library was designed with heavy load in mind, Tested with 10 concurrent tabs and a load of 1000 images, 6.32 seconds spent rendering.

To-Do

  • Add Event-Emitter based polling

  • Add support for multiple browsers, not just tabs

  • Add the ability to dynamically add tabs for larger loads, and remove some in lighter loads.

Can I make a PR?

Please! Any and all improvements are welcome, I have no guidelines, just make sure to document everything decently via JSDocs, and don't use implied any statements. Run on Repl.it

FAQs

Package last updated on 11 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc