npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-screenshot-app

v4.0.3

Published

electron module to create screenshots

Downloads

539

Readme

electron-screenshot-app Build Status

Make screenshots

Install

$ npm install electron-screenshot-app --save

Usage

var app = require('electron').app;
var screenshot = require('electron-screenshot-app');

  app.on('ready', function(){
    screenshot({
      url: 'http://sassdoc.com',
      width: 1920,
      height: 1080
    },
    function(err, image){
      // image.data is a Node Buffer
      // image.size contains width and height
      // image.devicePixelRatio will contain window.devicePixelRatio
    })
  });

API

screenshot(options, callback(err, img))

Takes a screenshots with options. The callback is called with an img object like

{
  data: <Buffer >
  size: {
    width: X
    height: N
  }
}

The screenshot is always saved as an png file.

options

url

Required Type: String

delay

Type: number (milliseconds)
Default: 0

Useful when the site does things after load that you want to capture.

width

Type: number Default: 0

Specify the with of the browser window

height

Type: number Default: 0

Specify the height of the browser window

crop

Type: Object
Default: undefined

A crop object may look like this:

{
  x : 10,
  y : 10,
  width : 100,
  height : 100
}
css

Type: String
Default: undefined

This css will be injected into the page before the screenshot is taken.

js

Type: String || Function
Default: undefined

This is either a String or a Function. If it is a String it must contain a function definition that takes on parameter e.g.

js: 'function(takeScreenshot){ /*Do some stuff*/ takeScreenshot();}'

or

js: 'takeScreenshot => { /*Do some stuff*/ takeScreenshot();}'

If it is a function you can just add it like:

js: function(takeScreenshot){ /*Do some stuff*/ takeScreenshot();}

or

js: (takeScreenshot) => { /*Do some stuff*/ takeScreenshot();}
transparent

Type: Boolean
Default: false

This will enable transparency. Keep in mind that most site do set a background color on the html/body tag. You can overwrite this by using the css option using something like html,body{ background-color: transparent !important;}.

page

Type: Boolean
Default: false

This will try to capture the whole page. width and height are considered the minimum size.

loadEvent

Type: String Default: undefined

The name of a custom page side event which can be used to trigger the page capture. This can be useful for client heavy javascript sites which take much longer to initialise than the time take to load the DOM. Such sites can send an event in the following manner.

    var evt = document.createEvent("Event");
    evt.initEvent("cust-loaded",true,true);
    document.dispatchEvent(evt);
format

Type: String Default: png

format to encode the image. only 'jpeg' or 'png' are supported

quality

Type: number Default: 80

If format is 'jpeg', defines the quality of the image '0-100'

Changelog

4.0.3
4.0.2
  • Fixed a bug where the wrong function was passed to the javascript function. (#8)
4.0.1
4.0.0
3.1.1
  • Fix screenshot bug on windows. See here.
3.1.0
  • Add support for specifying options.js to contain a JS function that will be executed.
3.0.2
  • Fix a bug in correctly merging nodeIntegration: false.
3.0.1
  • Improve page size detection.
3.0.0
  • Upgrade to [email protected]
  • Change option name of loadevent to loadEvent
  • Removed nodeIntegration. Use webPreferences.nodeIntegration instead.
  • Removed secure. Use webPreferences.webSecurity instead
2.2.0
  • Update to [email protected]
  • Add support for jpeg using the format option.
  • Add a custom loadevent that can be send by the page.
  • Make it possible to disable webSecurity via secure option.

Thanks to nealshail for these features.

2.1.0
2.0.0
1.1.2
  • Improve workaround introduced in 1.1.1
1.1.1
  • Add workaround for electron issue #2510 in electron >= 0.30.6 on a Mac
1.1.0
  • Use new dom-ready event (>[email protected]) to inject custom css into page before screenshot is taken.
  • Expose cleanup to callback to ensure that the window is closed after data was processed.
1.0.0
  • Inital release