{"id":13494278,"url":"https://github.com/nashaofu/node-screenshots","last_synced_at":"2026-02-07T03:03:22.435Z","repository":{"id":37854980,"uuid":"482195739","full_name":"nashaofu/node-screenshots","owner":"nashaofu","description":"Zero-dependent. A native nodejs screenshots library for Mac、Windows、Linux.","archived":false,"fork":false,"pushed_at":"2026-01-30T09:37:12.000Z","size":2693,"stargazers_count":360,"open_issues_count":8,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-31T01:19:11.007Z","etag":null,"topics":["linux","macos","native","nodejs","screenshot","windows","zero-dependencies"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nashaofu.png","metadata":{"files":{"readme":"README-zh_CN.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["nashaofu"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2022-04-16T08:13:45.000Z","updated_at":"2026-01-30T09:36:21.000Z","dependencies_parsed_at":"2024-04-27T09:29:21.625Z","dependency_job_id":"42741fd9-d712-4b8d-96c8-9037b1bedc3d","html_url":"https://github.com/nashaofu/node-screenshots","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/nashaofu/node-screenshots","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fnode-screenshots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fnode-screenshots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fnode-screenshots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fnode-screenshots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nashaofu","download_url":"https://codeload.github.com/nashaofu/node-screenshots/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nashaofu%2Fnode-screenshots/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29185116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"online","status_checked_at":"2026-02-07T02:00:07.217Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","macos","native","nodejs","screenshot","windows","zero-dependencies"],"created_at":"2024-07-31T19:01:23.412Z","updated_at":"2026-02-07T03:03:22.422Z","avatar_url":"https://github.com/nashaofu.png","language":"Rust","readme":"# 📸 node-screenshots\n\n`node-screenshots` 是一个基于[XCap](https://github.com/nashaofu/xcap)的原生的 node.js 截图库，支持 Mac、Windows 和 Linux 系统，且无需任何依赖。 支持截图与视频录制（待实现）。\n\n[English](README.md) | 简体中文\n\n## 支持矩阵\n\n### 操作系统\n\n| 操作系统          | node16 | node18 | node20 |\n| ----------------- | ------ | ------ | ------ |\n| Operating System  | node16 | node18 | node20 |\n| ----------------- | ------ | ------ | ------ |\n| Windows x64       | ✓      | ✓      | ✓      |\n| Windows x32       | ✓      | ✓      | ✓      |\n| Windows arm64     | ✓      | ✓      | ✓      |\n| macOS x64         | ✓      | ✓      | ✓      |\n| macOS arm64       | ✓      | ✓      | ✓      |\n| Linux x64 gnu     | ✓      | ✓      | ✓      |\n| Linux x64 musl    | ✓      | ✓      | ✓      |\n| Linux arm64 gnu   | ✓      | ✓      | ✓      |\n| Linux loongarch64 | ✓      | ✓      | ✓      |\n\n## 示例\n\n### Monitor\n\n```ts\nconst fs = require('fs')\nconst { Monitor } = require('node-screenshots')\n\nlet monitor = Monitor.fromPoint(100, 100)\n\nconsole.log(monitor, monitor.id())\n\nlet image = monitor.captureImageSync()\nfs.writeFileSync(`${monitor.id()}-sync.png`, image.toPngSync())\n\nmonitor.captureImage().then((data) =\u003e {\n  console.log(data)\n  fs.writeFileSync(`${monitor.id()}.jpeg`, data.toJpegSync())\n})\n\nconst monitors = Monitor.all()\n\nmonitors.forEach((item) =\u003e {\n  console.log(\n    'Monitor:',\n    item.id(),\n    item.name(),\n    [item.x(), item.y(), item.width(), item.height()],\n    item.rotation(),\n    item.scaleFactor(),\n    item.frequency(),\n    item.isPrimary(),\n  )\n})\n```\n\n### Window\n\n```ts\nconst fs = require('fs')\nconst { Window } = require('node-screenshots')\n\nlet windows = Window.all()\n\nwindows.forEach((item) =\u003e {\n  console.log({\n    id: item.id(),\n    x: item.x(),\n    y: item.y(),\n    y: item.z(),\n    width: item.width(),\n    height: item.height(),\n    rotation: item.rotation(),\n    scaleFactor: item.scaleFactor(),\n    isPrimary: item.isPrimary(),\n  })\n\n  let image = item.captureImageSync()\n  fs.writeFileSync(`${item.id()}-sync.bmp`, image.toBmpSync())\n\n  item.captureImage().then(async (data) =\u003e {\n    console.log(data)\n    let newImage = await data.crop(10, 10, 10, 10)\n    fs.writeFileSync(`${item.id()}.png`, await newImage.toPng())\n  })\n})\n```\n\n## API\n\n完整的 TypeScript 类型定义：[index.d.ts](./index.d.ts)\n\n### Monitor\n\n- `static all(): Array\u003cMonitor\u003e`：获取所有监视器\n- `static fromPoint(x: number, y: number): Monitor | null`：根据指定的坐标获取监视器\n- `captureImageSync(): Image`：同步捕获图像\n- `captureImage(): Promise\u003cImage\u003e`：异步捕获图像\n\n### Window\n\n- `static all(): Array\u003cWindow\u003e`：获取所有窗口\n- `captureImageSync(): Image`：同步捕获图像\n- `captureImage(): Promise\u003cImage\u003e`：异步捕获图像\n\n### Image\n\n- `cropSync(x: number, y: number, width: number, height: number): Image`：同步裁剪图像\n- `crop(x: number, y: number, width: number, height: number): Promise\u003cImage\u003e`：异步裁剪图像\n- `toPngSync(copyOutputData?: boolean | undefined | null): Buffer`：同步转换为 PNG 格式\n- `toPng(copyOutputData?: boolean | undefined | null): Promise\u003cBuffer\u003e`：异步转换为 PNG 格式\n- `toJpegSync(copyOutputData?: boolean | undefined | null): Buffer`：同步转换为 JPEG 格式\n- `toJpeg(copyOutputData?: boolean | undefined | null): Promise\u003cBuffer\u003e`：异步转换为 JPEG 格式\n- `toBmpSync(copyOutputData?: boolean | undefined | null): Buffer`：同步转换为 BMP 格式\n- `toBmp(copyOutputData?: boolean | undefined | null): Promise\u003cBuffer\u003e`：异步转换为 BMP 格式\n- `toRawSync(copyOutputData?: boolean | undefined | null): Buffer`：同步转换为原始格式（RGBA 数据）\n- `toRaw(copyOutputData?: boolean | undefined | null): Promise\u003cBuffer\u003e`：异步转换为原始格式（RGBA 数据）\n\n`copyOutputData`: electron 中传递传递相关参数，否则 electron 会崩溃，nodejs 不传或者传递 false，性能会更好，详细信息参考 https://github.com/napi-rs/napi-rs/issues/1346\n\n## Linux 系统需求\n\n在 Linux 上，你需要安装 `libxcb`、`libxrandr` 和 `dbus`。\n\nDebian / Ubuntu：\n\n```sh\napt-get install libxcb1 libxrandr2 libdbus-1-3\n```\n\nAlpine：\n\n```sh\napk add libxcb libxrandr dbus\n```\n\n## 相关仓库\n\n- [xcap](https://github.com/nashaofu/xcap) - XCap 是一个使用 Rust 编写的跨平台的屏幕捕获库\n","funding_links":["https://github.com/sponsors/nashaofu"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnashaofu%2Fnode-screenshots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnashaofu%2Fnode-screenshots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnashaofu%2Fnode-screenshots/lists"}