Code Monkey home page Code Monkey logo

screenshot-desktop's Introduction

screenshot-desktop

Capture a screenshot of your local machine

  • Multi/Cross Platform
    • Linux: required ImageMagick apt-get install imagemagick
    • OSX: No dependencies required!
    • Windows: No dependencies required!
  • Promise based API
  • JPG output (by default)

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

  • filename Optional. Absolute or relative path to save output.
  • format Optional. Valid values png|jpg.
  • linuxLibrary Optional. Linux only. Valid values scrot|imagemagick. Which library to use. Note that scrot does not support format or screen selection.

Licence

MIT ยฉ Ben Evans

screenshot-desktop's People

Contributors

renovate-bot avatar bencevans avatar depfu[bot] avatar dependabot[bot] avatar renovate[bot] avatar tai2 avatar bgschiller avatar blatoy avatar radar155 avatar pityulin avatar yarvik avatar timlg07 avatar ties-s avatar si458 avatar phollome avatar nicolasnewman avatar rajsite avatar marcincichocki avatar levinunnink avatar nkns165 avatar dangilkerson avatar yandevde avatar 0xganz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.