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

easy-screen-capture

v2.0.1

Published

A webpage capture tool built over puppeteer, use headless chrome to take screenshot of page in any possible viewport for UI designers and developers in RWD

Downloads

28

Readme

Easy Screen Capture

A webpage capture NPM package built over puppeteer, use headless chrome to take screenshot of page in any possible viewport for UI designers and developers in RWD

About:

Capture screenshot by calling function capture which requires 3 parameters width, height, URL respectively.

Installation:

  • To download and save in package.json file

      npm install --save easy-screen-capture
  • To download without saving

      npm install easy-screen-capture

Usage:

Initialization:

    var easyScreenCapture = require("easy-screen-capture")

Capture Method:

This method captures the screenshot of the page in your required viewport

    easyScreenCapture.capture(viewports, urls, directory)
    

parameters:

  • viewports: It is an array of objects. each object containing height and width property to specify the height and width of the viewport

  • urls: It is an array of url's for whose you want to capture screenshots.

  • directory:(optional) This is an optional parameter specify the path to save your screenshots. By default it is "assets-easy-screen-capture" located in the same directory in which the calling script exists.

Capturing Screenshot in default directory:

var viewports = [{
    height: 736,
    width: 414
}, {
    height: 1080,
    width: 1920
}]

let url = "https://www.google.com";
easyScreenCapture.capture(viewports, urls)

Capture screenshot to custom directory:

var viewports = [{
    height: 736,
    width: 414
}, {
    height: 1080,
    width: 1920
}]

let url = "https://www.google.com";
let directory = "/path/to/desired/directory";
easyScreenCapture.capture(viewports, url, directory)

you can also pass multiple urls using the array of urls as we have done in the previous code example

Capture screenshot with multiple urls:

var viewports = [{
    height: 736,
    width: 414
}, {
    height: 1080,
    width: 1920
}]

var urls = [{
        url: "https://www.google.com"
    },
    {
        url: "https://github.com/JDchauhan/easy-screen-capture"
    },
    {
        name: "npm",
        url: "https://www.npmjs.com/~jdchauhan"
    }
]

easyScreenCapture.capture(viewports, urls, directory);

Set output directory:

you can also save the file to a custom directory. for this you need to set the directory using

    easyScreenCapture.setDir("/path/to/desired/directory");

before call to capture();

Set time to wait for browser instance to start :

It is used to set maximum time in milliseconds to wait for the browser instance to start.

  • Defaults to 30000 (30 seconds).

  • Pass 0 to disable timeout.

      easyScreenCapture.setTimeOut(0);

Results:

Using above code would create a folder in directory "assets-easy-screen-capture" located in the same directory in which the calling script exists.

All your captured PNG files are saved in this directory.

On successfull execution of code you will get a message saying it has been successfully captured.

In case of error you get errors in console as well as.

deprecations from previous version:

The capture() method has been deprecated in this method. This method accepts only the url, height and width in previous versions but in this version it accepts an array of object for multiple viewports and an array of urls

dependencies:

  • Puppeteer
  • File-system

Core Contributors:

Please submit bug reports to https://github.com/JDchauhan/easy-screen-capture.

Pull requests are welcome.