{"id":25692641,"url":"https://github.com/jonschlinkert/cross-capture","last_synced_at":"2025-04-24T05:49:33.281Z","repository":{"id":278188458,"uuid":"934808219","full_name":"jonschlinkert/cross-capture","owner":"jonschlinkert","description":"Capture screenshots programmatically. Cross-platform, with support for MacOS (Darwin), Windows, and Linux.","archived":false,"fork":false,"pushed_at":"2025-02-18T14:32:43.000Z","size":23,"stargazers_count":27,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-24T05:49:25.456Z","etag":null,"topics":["capture","cross-platform","darwin","image","linux","macos","screen-capture","screenshot","screenshots","windows"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"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},"funding":{"github":"jonschlinkert"}},"created_at":"2025-02-18T12:44:23.000Z","updated_at":"2025-03-28T09:24:59.000Z","dependencies_parsed_at":"2025-02-18T13:39:06.546Z","dependency_job_id":"cb8a0300-09a0-4ba8-81c3-d5d08f7fcbcb","html_url":"https://github.com/jonschlinkert/cross-capture","commit_stats":null,"previous_names":["jonschlinkert/cross-capture"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fcross-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fcross-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fcross-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fcross-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/cross-capture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250573345,"owners_count":21452345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["capture","cross-platform","darwin","image","linux","macos","screen-capture","screenshot","screenshots","windows"],"created_at":"2025-02-24T23:27:59.400Z","updated_at":"2025-04-24T05:49:33.261Z","avatar_url":"https://github.com/jonschlinkert.png","language":"TypeScript","funding_links":["https://github.com/sponsors/jonschlinkert"],"categories":[],"sub_categories":[],"readme":"# cross-capture [![NPM version](https://img.shields.io/npm/v/cross-capture.svg?style=flat)](https://www.npmjs.com/package/cross-capture) [![NPM monthly downloads](https://img.shields.io/npm/dm/cross-capture.svg?style=flat)](https://npmjs.org/package/cross-capture) [![NPM total downloads](https://img.shields.io/npm/dt/cross-capture.svg?style=flat)](https://npmjs.org/package/cross-capture)  [![Tests](https://github.com/jonschlinkert/cross-capture/actions/workflows/test.yml/badge.svg)](https://github.com/jonschlinkert/cross-capture/actions/workflows/test.yml)\n\n\u003e Capture screenshots programmatically. Cross-platform, with support for MacOS (Darwin), Windows, and Linux.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save cross-capture\n```\n\n## Usage\n\n```js\nimport {\n  capture, // Automatically detect platform\n  captureLinux, // Capture on Linux\n  captureDarwin, // Capture on MacOS\n  captureWindows // Capture on Windows\n} from 'cross-capture';\n\ncapture({\n  cursor: true\n  format: 'png', // this is the default\n  window: { interactive: true } // this is the default\n})\n```\n\n## Requirements\n\n* macOS: Built-in support\n* Linux: One of:\n  - grim + slurp (Wayland)\n  - maim (X11)\n  - ImageMagick (import command)\n* Windows: PowerShell 5.0+\n\n## API\n\n### capture\n\nTake a screenshot with the specified options. Returns a Promise that resolves to a base64-encoded image or an error object.\n\n```js\nimport { capture } from 'cross-capture';\n\n// Take a full screen screenshot\nconst result = await capture();\nconsole.log(result.data); // Base64 encoded PNG\n\n// Take a screenshot of a specific region\nconst region = await capture({\n  region: { x: 0, y: 0, width: 800, height: 600 }\n});\n```\n\n### captureDarwin\n\nmacOS-specific screenshot function using the `screencapture` command. Supports window capture by ID or title and includes interactive window selection.\n\n```js\nimport { captureDarwin } from 'cross-capture';\n\n// Capture active window with cursor\nconst screenshot = await captureDarwin({\n  window: { interactive: true },\n  cursor: true\n});\n\n// Capture specific window by title\nconst terminal = await captureDarwin({\n  window: { title: 'Terminal' }\n});\n\n// Capture window by ID\nconst byId = await captureDarwin({\n  window: { id: '12345' }\n});\n```\n\n### captureLinux\n\nLinux-specific screenshot function that automatically detects and uses the appropriate tools:\n\n* Wayland: Uses `grim` for capture and `slurp` for selection\n* X11: Uses `maim` for capture and `xdotool` for window management\n\n```js\nimport { captureLinux } from 'cross-capture';\n\n// Capture window by title\nconst browser = await captureLinux({\n  window: { title: 'Firefox' }\n});\n\n// Capture region with cursor\nconst region = await captureLinux({\n  cursor: true,\n  region: {\n    x: 100,\n    y: 100,\n    width: 500,\n    height: 300\n  }\n});\n\n// Interactive selection (uses slurp on Wayland, maim -s on X11)\nconst selected = await captureLinux();\n```\n\n### captureWindows\n\nWindows-specific screenshot function using PowerShell and Windows Forms. Interactive selection is implemented via a semi-transparent form overlay. Window capture requires exact window title match.\n\n```js\nimport { captureWindows } from 'cross-capture';\n\n// Interactive region selection\nconst region = await captureWindows();\n\n// Capture specific window\nconst notepad = await captureWindows({\n  window: { title: 'Untitled - Notepad' }\n});\n\n// Capture region as JPG\nconst jpg = await captureWindows({\n  format: 'jpg',\n  region: {\n    x: 0,\n    y: 0,\n    width: 1920,\n    height: 1080\n  }\n});\n```\n\n### Options\n\nThe following options can be passed to the capture functions:\n\n#### interactive\n\nType: `boolean`\nDefault: `false`\n\nEnable interactive selection mode (where supported).\n\n```js\nconst screenshot = await capture({ interactive: true });\n```\n\n#### cursor\n\nType: `boolean`\nDefault: `false`\n\nInclude the cursor in the screenshot.\n\n```js\nconst withCursor = await capture({ cursor: true });\n```\n\n#### format\n\nType: `string`\nDefault: `'png'`\n\nOutput format for the screenshot. Supported values: `'png'`, `'jpg'`.\n\n```js\nconst jpgScreenshot = await capture({ format: 'jpg' });\n```\n\n#### quality\n\nType: `number`\nDefault: `100`\n\nJPEG quality (0-100) when using `format: 'jpg'`.\n\n```js\nconst compressed = await capture({\n  format: 'jpg',\n  quality: 80\n});\n```\n\n#### region\n\nType: `object`\n\nCapture a specific region of the screen.\n\nProperties:\n\n* `x` (number): X coordinate\n* `y` (number): Y coordinate\n* `width` (number): Width of region\n* `height` (number): Height of region\n\n```js\nconst region = await capture({\n  region: {\n    x: 100,\n    y: 100,\n    width: 500,\n    height: 300\n  }\n});\n```\n\n#### window\n\nType: `object`\n\nCapture a specific window.\n\nProperties:\n\n* `title` (string): Window title to match\n* `id` (string): Window ID (macOS only)\n* `interactive` (boolean): Interactive window selection\n\n```js\n// Capture by window title\nconst window = await capture({\n  window: { title: 'Terminal' }\n});\n\n// Interactive window selection (macOS)\nconst selected = await capture({\n  window: { interactive: true }\n});\n```\n\n#### tempFile\n\nType: `string`\n\nCustom temporary file path for the screenshot.\n\n```js\nconst custom = await capture({\n  tempFile: '/tmp/my-screenshot.png'\n});\n```\n\n## Release History\n\n### v1.0.0\n\n* Initial release with cross-platform support\n* Basic screenshot capabilities\n* Window and region capture support\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2025, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the MIT License.\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on February 18, 2025._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fcross-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fcross-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fcross-capture/lists"}