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

page2image

v2.1.0

Published

📷 page2image is an npm package for taking screenshot which also provides CLI command

Downloads

29

Readme

📷 page2image

npm version Total downloads Build Status PRs Welcome Greenkeeper badge MIT Licence

page2image is an npm package using Headless Chrome for taking screenshots which also provides CLI command

Using By Module 📦

Install

npm i page2image --save

Quick Examples

import Screenshot from 'page2image';

const screenshot = new Screenshot({
  waitUntil: 'networkidle2',
  viewportConfig: { width: 1920, height: 1080 },
  screenshotConfig: { fullPage: true, path: 'screenshot.png' },
});

screenshot
  .takeScreenshot('https://github.com/Runjuu')
  .then(process.exit);

Methods

takeScreenshot(url:string)

Accept a url string as an argument and return an image Buffer

init(Config)

Accept a Config object and next time calling takeScreenshot will using new config to take screenshot

Config: {}


Using By CLI ⌨️

Install

npm i page2image --global

Quick Examples

# Single page
> page2image https://github.com/Runjuu --type=jpeg --quality=80

# Multi-page
> page2image https://github.com/Runjuu https://github.com/Runjuu --type=jpeg --quality=80

# Local file
> page2image ./index.html --type=jpeg --quality=80

Args <argv>: <default value>

width: 1366

Page width in pixels.

height: 768

Page height in pixels, default will take a full page screenshot.

type: png

Specify screenshot type, could be either 'jpeg' or 'png'.

quality: 100

The quality of the image, between 0-100. Not applicable to png images.

dpr: 2

Specify device scale factor.

selector: null

take a screenshot for the selected element

page2image https://github.com/Runjuu --selector=".js-contribution-graph"

disableJS: false

To disable JavaScript on the page.

waitUntil: networkidle2

When to consider navigation succeeded. more details

sleep: 0

if sleep is a number

Wait ${sleep} milliseconds to take screenshot.

if sleep is a selector

Wait for the selector to appear in page

emulate: false

List of all available devices is available in the source code. Below is an example of using emulate args to emulate iPhone 6

page2image https://github.com/Runjuu --emulate=iPhone6 

scrollToBottom: false

Wait till viewport scroll to the bottom of the page

named: <default using url to named>

Name of screenshot

path: <default using current path>

Path to save the screenshot

page2image https://github.com/Runjuu --path=../
page2image https://github.com/Runjuu --path=/User/someone/
page2image https://github.com/Runjuu --path=~/Downloads

To Do

  • [x] take screenshots via url
  • [x] take screenshots from local html file
  • [ ] take multiple screenshots from file

🤔 have any questions? 👉 new issues 😉