bencevans / screenshot-desktop

💻 Capture a screenshot of your local machine
https://www.npmjs.com/package/screenshot-desktop
437 stars 91 forks source link
hacktoberfest linux osx screenshot windows

screenshot-desktop

Capture a screenshot of your local machine

Install

$ npm install --save screenshot-desktop

Usage

const screenshot = require('screenshot-desktop')

screenshot().then((img) => {
  // img: Buffer filled with jpg goodness
  // ...
}).catch((err) => {
  // ...
})
const screenshot = require('screenshot-desktop')

screenshot({format: 'png'}).then((img) => {
  // img: Buffer filled with png goodness
  // ...
}).catch((err) => {
  // ...
})
screenshot.listDisplays().then((displays) => {
  // displays: [{ id, name }, { id, name }]
  screenshot({ screen: displays[displays.length - 1].id })
    .then((img) => {
      // img: Buffer of screenshot of the last display
    });
})
screenshot.all().then((imgs) => {
  // imgs: an array of Buffers, one for each screen
})
screenshot({ filename: 'shot.jpg' }).then((imgPath) => {
  // imgPath: absolute path to screenshot
  // created in current working directory named shot.png
});

// absolute paths work too. so do pngs
screenshot({ filename: '/Users/brian/Desktop/demo.png' })

screenshot() options

Licence

MIT © Ben Evans