node-screenshots

nashaofuMIT更新放缓

零依赖的 Node.js 原生截图库,支持 Mac、Windows、Linux 三平台,用 Rust 实现,适合在服务端或桌面应用中直接调用系统能力截屏。

Zero-dependent. A native nodejs screenshots library for Mac、Windows、Linux.

v0.2.8发布于 2026-02-07 03:43 UTC383star25fork同步于 2026-11-07 07:33 UTC

怎么上手

README 里没有找到可直接复制的安装命令

README 里没有找到可直接复制的安装命令,请到 README 或官方文档查看安装方式。

硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v0.2.8
  1. v0.2.8最新正式版2026-02-07 · 2026-02-07 03:43 UTC

    Changes

    • feat: 修改ci @nashaofu (#60)

    Full Changelog: https://github.com/nashaofu/node-screenshots/compare/v0.2.7...v0.2.8

  2. v0.2.72026-02-07 · 2026-02-07 01:41 UTC
    查看更新说明

    Changes

    • feat: 添加arm64 @nashaofu (#59)

    Full Changelog: https://github.com/nashaofu/node-screenshots/compare/v0.2.6...v0.2.7

  3. v0.2.62026-01-30 · 2026-01-30 13:38 UTC
    查看更新说明

    Changes

    • chore: change version @nashaofu (#58)
    • feat: 增加龙架构支持并在 CI 里预构建龙架构二进制 @SkyBird233 (#57)

    Full Changelog: https://github.com/nashaofu/node-screenshots/compare/v0.2.5...v0.2.6

  4. v0.2.52025-12-14 · 2025-12-14 15:13 UTC

    这个版本没有写更新说明。

  5. v0.2.42025-04-12 · 2025-04-12 06:15 UTC
    查看更新说明

    Changes

    • feat: 升级xcap @nashaofu (#50)

    Full Changelog: https://github.com/nashaofu/node-screenshots/compare/v0.2.3...v0.2.4

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    📸 node-screenshots

    node-screenshots is a native node.js screenshot library based on XCap, It supports Mac, Windows, and Linux systems without any dependencies. node-screenshots supports screenshot and video recording (to be implemented).

    English | 简体中文

    Support Matrix

    Operating System

    Operating Systemnode16node18node20
    Windows x64✓✓✓
    Windows x32✓✓✓
    Windows arm64✓✓✓
    macOS x64✓✓✓
    macOS arm64✓✓✓
    Linux x64 gnu✓✓✓
    Linux x64 musl✓✓✓
    Linux arm64 gnu✓✓✓
    Linux loongarch64✓✓✓

    Example

    Monitor

    const fs = require('fs')
    const { Monitor } = require('node-screenshots')
    
    let monitor = Monitor.fromPoint(100, 100)
    
    console.log(monitor, monitor.id())
    
    let image = monitor.captureImageSync()
    fs.writeFileSync(`${monitor.id()}-sync.png`, image.toPngSync())
    
    monitor.captureImage().then((data) => {
      console.log(data)
      fs.writeFileSync(`${monitor.id()}.jpeg`, data.toJpegSync())
    })
    
    const monitors = Monitor.all()
    
    monitors.forEach((item) => {
      console.log(
        'Monitor:',
        item.id(),
        item.name(),
        [item.x(), item.y(), item.width(), item.height()],
        item.rotation(),
        item.scaleFactor(),
        item.frequency(),
        item.isPrimary(),
      )
    })
    

    Window

    const fs = require('fs')
    const { Window } = require('node-screenshots')
    
    let windows = Window.all()
    
    windows.forEach((item) => {
      console.log({
        id: item.id(),
        x: item.x(),
        y: item.y(),
        y: item.z(),
        width: item.width(),
        height: item.height(),
        rotation: item.rotation(),
        scaleFactor: item.scaleFactor(),
        isPrimary: item.isPrimary(),
      })
    
      let image = item.captureImageSync()
      fs.writeFileSync(`${item.id()}-sync.bmp`, image.toBmpSync())
    
      item.captureImage().then(async (data) => {
        console.log(data)
        let newImage = await data.crop(10, 10, 10, 10)
        fs.writeFileSync(`${item.id()}.png`, await newImage.toPng())
      })
    })
    

    API

    Full typeScript type definition: index.d.ts

    Monitor

    • static all(): Array<Monitor>: Get all monitor
    • static fromPoint(x: number, y: number): Monitor | null: Get a monitor from the specified coordinates
    • captureImageSync(): Image: Synchronously capture image
    • captureImage(): Promise<Image>: Asynchronously capture image

    Window

    • static all(): Array<Window>: Get all window
    • captureImageSync(): Image: Synchronously capture image
    • captureImage(): Promise<Image>: Asynchronously capture image

    Image

    • cropSync(x: number, y: number, width: number, height: number): Image: Synchronously crop image
    • crop(x: number, y: number, width: number, height: number): Promise<Image>: Asynchronously crop image
    • toPngSync(copyOutputData?: boolean | undefined | null): Buffer:Synchronously Convert to png
    • toPng(copyOutputData?: boolean | undefined | null): Promise<Buffer>: Asynchronously Convert to png
    • toJpegSync(copyOutputData?: boolean | undefined | null): Buffer: Synchronously Convert to jpeg
    • toJpeg(copyOutputData?: boolean | undefined | null): Promise<Buffer>: Asynchronously Convert to jpeg
    • toBmpSync(copyOutputData?: boolean | undefined | null): Buffer: Synchronously Convert to bmp
    • toBmp(copyOutputData?: boolean | undefined | null): Promise<Buffer>: Asynchronously Convert to bmp
    • toRawSync(copyOutputData?: boolean | undefined | null): Buffer: Synchronously Convert to raw(RGBA data)
    • toRaw(copyOutputData?: boolean | undefined | null): Promise<Buffer>: Asynchronously Convert to raw(RGBA data)

    copyOutputData: pass related parameters in electron, otherwise electron will crash, nodejs does not pass or passes false, performance will be better, for more information refer to https://github.com/napi-rs/napi-rs/issues/1346

    Linux System Requirements

    On Linux, you need to install libxcb, libxrandr, and dbus.

    Debian / Ubuntu:

    apt-get install libxcb1 libxrandr2 libdbus-1-3
    

    Alpine:

    apk add libxcb libxrandr dbus
    

    Related Repositories

    • xcap - XCap is a cross-platform screen capture library written in Rust