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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mscststs/screenshot-rs

v2.0.2

Published

Rust-based screen capture N-API addon returning Blob (PNG)

Downloads

22

Readme

screenshot-rs

Rust-based screen capture exposed to Node via N-API. Provides a single async API that returns a PNG Blob.

Installation

npm install screenshot-rs

Note: This package compiles the native module during installation. You need:

  • Rust toolchain (install from https://rustup.rs/)

The package will automatically build the native module for your platform during npm install using npx.

Prerequisites

  • Node.js >= 16.17
  • Rust toolchain (https://rustup.rs/)
  • macOS, Windows, or Linux with display access

Development Setup

Development Setup

Install dev deps

cd /Users/jiangzhe/repo/github/screenshot-rs
npm install

Build

cd /Users/jiangzhe/repo/github/screenshot-rs
npm run build

This produces a platform-specific .node binary in the package directory.

Build for all platforms

npm run build:all

This builds binaries for all supported platforms.

Troubleshooting

If you encounter build issues:

  1. Ensure Rust is installed: rustc --version
  2. Ensure you have internet connection for npx to download @napi-rs/cli
  3. Try running npm install again
  4. Check that you have the necessary system dependencies for your platform

Usage

ES Modules

import {
  captureScreenshotBlob,
  listScreens,
  captureScreenshotByScreenId,
} from "screenshot-rs";

// Capture primary screen
const blob = await captureScreenshotBlob();
console.log("Got blob:", blob.type, blob.size);

// List all screens
const screens = await listScreens();
console.log("Available screens:", screens);

// Capture specific screen
if (screens.length > 0) {
  const screenBlob = await captureScreenshotByScreenId(screens[0].id);
  console.log("Screen blob:", screenBlob.type, screenBlob.size);
}

CommonJS

const {
  captureScreenshotBlob,
  listScreens,
  captureScreenshotByScreenId,
} = require("screenshot-rs");

(async () => {
  const blob = await captureScreenshotBlob();
  console.log("Got blob:", blob.type, blob.size);
})();

Example: save PNG to disk

See full-path example at: /Users/jiangzhe/repo/github/screenshot-rs/examples/save-png.js

Run:

node /Users/jiangzhe/repo/github/screenshot-rs/examples/save-png.js

API

Functions

  • async captureScreenshotBlob(): Promise<Blob>

    • Captures the primary display and returns a PNG Blob.
  • async listScreens(): Promise<ScreenInfo[]>

    • Returns information about all available screens.
  • async captureScreenshotByScreenId(screenId: number): Promise<Blob>

    • Captures a specific screen by ID and returns a PNG Blob.

Types

interface ScreenInfo {
  id: number;
  x: number;
  y: number;
  width: number;
  height: number;
  rotation: number;
  scaleFactor: number;
  frequency: number;
  isPrimary: boolean;
}

Platform Support

  • ✅ macOS (x64, arm64)
  • ✅ Windows (x64)
  • ✅ Linux (x64, arm64)

Permissions

macOS

On macOS, you may need to grant screen recording permissions:

  1. Go to System Preferences > Security & Privacy > Privacy > Screen Recording
  2. Add your application to the list of allowed apps

Linux

On Linux, ensure your display server (X11/Wayland) is properly configured.

Windows

On Windows, no additional permissions are typically required.

License

MIT