New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rasterizeelement

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rasterizeelement

rasterize and crop the contents of specified DOM selector

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

rasterizeElement.js

Expands the functionality of rasterizeHTML.js to rasterize the contents of specified element. It supports everything that is supported by rasterizeHTML.js.

Install:

$ npm install rasterizeelement.js

Then use it via require('rasterizeelement') or use browserify builds from dist/rasterizeElement.js or dist/rasterizeElement.min.js in <script/> tag.

Example:

rasterizeElement.rasterize('#my-content', options, function(imgBase64){
  var img = document.createElement('img');
  img.src = imgBase64;
  document.appendChild(img);
});

Options:

OptiontypeDefaultDescription
encodingstring'png'Lets you choose the encoding of image such as 'png', 'jpg' or 'jpeg'.
qualitynumber1.0Should be between 0 to 1. 0 being lowest quality and 1 being the highest possible quality.
shouldClonebooleanfalseClones the document before rasterizing. Use this when you want to capture dynamic content that changes often.
canvasFillStylestring'#FFFFFF'Default background color of rasterized image.
var options = {
  encoding: 'png',
  quality: 1.0.
  shouldClone: false,
  canvasFillStyle: '#FFFFFF'
}

How it works?

The drill here is pretty simple. An entire document is rasterized on temporary canvas using rasterizeHTML. Temporary canvas is then resized using specified element's height, width, left offset and top offset and converted into base64 encoding.

Development:

  1. clone this repository
  2. cd into rasterizeElement.js
  3. run npm install
  4. run grunt build to manually build files in dist OR run grunt watch to auto build files as files in src changes

Keywords

FAQs

Package last updated on 15 Nov 2015

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