Skip to content
Capture screenshots using Chrome's new headless mode.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial commit Sep 16, 2017
.npmignore fix npmignore Sep 23, 2017
.travis.yml initial commit Sep 16, 2017
README.md
example.js initial commit Sep 16, 2017
example.png use pupeteer, add .wait option Aug 16, 2018
index.js
package-lock.json 3.0.1 Jun 5, 2019
package.json 3.0.1 Jun 5, 2019
test.js

README.md

capture-chrome

Capture screenshots using Chrome's new headless mode. This means it does not require a graphical environment / X server to run!

Also you don't even need to have Chromium or Chrome installed, this will fetch an up to date binary for you.

build status Greenkeeper badge

Example

Capture a 1024x768 screenshot of github.com:

const capture = require('capture-chrome')
const fs = require('fs')

capture({
  url: 'https://github.com/'
}).then(screenshot => {
  fs.writeFileSync(`${__dirname}/example.png`, screenshot)
  console.log('open example.png')
})

github.com

API

screenshot({ url, width = 1024, height = 768, wait = 0 })

Capture a screenshot of url, returns a Promise which resolves with a buffer.

Options:

  • url Page url
  • width Viewport width
  • height Viewport height
  • wait Time in ms to wait after the page finished loading all resources

Installation

With npm do:

npm install capture-chrome

CI

This project will work in CI environments like Travis and AppVeyor without any additional configuration. It fetches Chromium itself and doesn't need a X server to run.

Related projects

License

(MIT)

Copyright (c) 2017 Julian Gruber <julian@juliangruber.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.