New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "node-image-from-html",
"version": "2.0.0",
"version": "2.0.1",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "A Furry Account - Furry",

# node-image-from-html
Convert HTML data into images using Puppeteer.
Convert HTML data into images, with a persistant headless browser!
## Features
* A Polling-Based queueing system for jobs. You can specify {x} number of pages to spawn, and if one is in the middle of processing html, it will select another, or if there are no others, it will wait for it to finish.
* An always-active Puppeteer instance, taking away the need to spawn an instance and close it after each job, as all the other libraries seem to do.
* Class/ID OR whole-page selection options, so you can just get an image of the piece you're after.
* Base64 output
* 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

@@ -16,10 +21,10 @@

(async () => { // For async operations
(async () => {
const Handler = new ImageFromHtml.Browser(1)
const Handler = new ImageFromHtml.BrowserHandler(1, { headless: true })
await Handler.start() // Create the webkit
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")
// 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")

@@ -31,9 +36,18 @@ fs.writeFileSync("myImage.png", base64, {encoding: "base64"})

## Why?
## Efficiency?
Because I'm sick of using canvas to create and modify images in nodejs, so I thought this would be a nice useful replacement.
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 do, I threw this together in an hour. So any ideas/changes would be lovely.
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.
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