desktop-screenshot-plus
v1.1.0
Published
Cross-platform screenshot module, using external tools
Maintainers
Readme
desktop-screenshot-plus
Cross-platform screenshot module for Node.js, using platform-specific external tools included with the package.
Forked from senzil/node-desktop-screenshot.
Original project: johnvmt/node-desktop-screenshot.
Author: Darshan Limbani
Install
npm install desktop-screenshot-plusSupported platforms
- Windows (win32) — uses nircmd
- macOS (darwin)
- Linux — uses scrot
Available options
- buffered — return a Buffer instead of saving a file.
- multi — enable snapshot of all present displays (display current).
- quality — JPEG quality (0 to 100).
- width — use with height, or alone to keep aspect ratio.
- height — use with width, or alone to keep aspect ratio.
- timestamp —
true/falseto print datetime on screenshot (default:true). - caption — string to print before the timestamp.
- env — environment key/value variables for the screenshot process.
Returns
A Promise (callbacks are also supported).
- If
buffered: true→ returns a Buffer. - If saving to a file → returns the file path.
Examples
Full resolution
var screenshot = require('desktop-screenshot-plus');
screenshot("screenshot.png", function(error, complete) {
if (error)
console.log("Screenshot failed", error);
else
console.log("Screenshot succeeded");
});Resize to 400px wide, maintain aspect ratio
var screenshot = require('desktop-screenshot-plus');
screenshot("screenshot.png", { width: 400 }, function(error, complete) {
if (error)
console.log("Screenshot failed", error);
else
console.log("Screenshot succeeded");
});Resize to 400x300, set JPG quality to 60%
var screenshot = require('desktop-screenshot-plus');
screenshot("screenshot.jpg", { width: 400, height: 300, quality: 60 }, function(error, complete) {
if (error)
console.log("Screenshot failed", error);
else
console.log("Screenshot succeeded");
});TODOs
- Cropping
License
MIT
