# clipboard-image

> Get and set images on the macOS clipboard

Latest version **0.1.0** (published 2025-08-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install clipboard-image
pnpm add clipboard-image
yarn add clipboard-image
bun add clipboard-image
```

Provides the command `clipboard-image`.

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2025-08-27 |
| First published | 2025-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 50 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | clipboard, image, images, pasteboard, macos, mac, copy, paste, nspasteboard |

## Links

- npm: https://www.npmjs.com/package/clipboard-image
- Repository: https://github.com/sindresorhus/clipboard-image
- Homepage: https://github.com/sindresorhus/clipboard-image#readme
- Issues: https://github.com/sindresorhus/clipboard-image/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/clipboard-image

## Dependencies (1)

- [run-jxa](https://npm.io/package/run-jxa.md) ^3.0.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2025-08-27

## README

# clipboard-image

> Get and set images on the macOS clipboard

## Install

```sh
npm install clipboard-image
```

## Usage

```js
import {
	writeClipboardImages,
	readClipboardImages
} from 'clipboard-image';

await writeClipboardImages(['screenshot.png', 'photo.jpg']);

console.log(await readClipboardImages());
//=> ['/var/folders/.../clipboard-image-1.png', '/var/folders/.../clipboard-image-2.png']
```

## API

### `hasClipboardImages()`

Check if there are images on the clipboard.

Returns a `Promise<boolean>`.

On non-macOS platforms, it returns `false`.

### `readClipboardImages()`

Read images from the clipboard.

You get PNG files no matter what image types they were on the clipboard to make it easier to handle.

Returns a `Promise<string[]>` with paths to the saved PNG files. You are in charge of these files. You can move them somewhere else or clean them up when you are done.

On non-macOS platforms, it returns an empty array.

### `writeClipboardImages(filePaths)`

Write images to the clipboard.

Supports any image type that macOS supports, which includes PNG, JPEG, HEIC, WebP, GIF.

On non-macOS platforms, it does nothing.

#### filePaths

Type: `Array<string | URL>`

An array of file paths and file URL objects pointing to image files.

## CLI

```sh
# Read images from clipboard and output file paths
clipboard-image

# Write images to clipboard
clipboard-image image1.png image2.jpg
```

When reading from clipboard, if there are images, they will be saved to a temporary directory and the file paths will be printed (one per line).

When writing to clipboard, provide one or more image file paths as arguments.

## Related

- [clipboardy](https://github.com/sindresorhus/clipboardy) - Access text on the system clipboard (copy/paste)
- [copy-text-to-clipboard](https://github.com/sindresorhus/copy-text-to-clipboard) - Copy text to the clipboard in the browser

---
_Source: https://npm.io/package/clipboard-image · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
