Demo
$ imgclip --watch
imgclip: saved ~/Pictures/imgclip/imgclip-1746359527000-1.png
imgclip: saved ~/Pictures/imgclip/imgclip-1746359595000-2.png
$ imgclip --interactive
imgclip: interactive mode — watching clipboard for changes
[s] save [d] discard [q] quit
imgclip: new image (1920x1080) [s]ave [d]iscard [q]uit? s
imgclip: saved ~/Pictures/imgclip/imgclip-1746359722000-1.png
imgclip: new image (800x600) [s]ave [d]iscard [q]uit? d
imgclip: discarded
How it works
Copy / Screenshot ──▶ Clipboard ──▶ imgclip ──▶ File / stdout / data URI
│
┌───────────────┼───────────────┐
│ │ │
One-shot Watch Interactive
(save once) (auto-save) (choose per image)
A minimal CLI tool to extract images from the clipboard and save them as files, pipe them to stdout, or convert them to data URIs. Also copies image files to the clipboard. Supports a watch mode that automatically saves new clipboard images, and an interactive mode that lets you selectively save or discard each one.
- Zero-config auto-start —
imgclip --installsets up login auto-start; clipboard images are saved automatically on every session. - Single binary, zero runtime deps — Static release build, no installer, no framework. Just drop it in your PATH.
- Four modes in one tool — One-shot capture, continuous watch, interactive selective save, and file-to-clipboard copy.
- Flexible output — Write to file, pipe to stdout, generate a
data:image/...URI, or create a temp file and print the path. - Cross-platform — First-class support for Windows, Linux, and macOS (x86_64 + ARM).
- Pipeline-friendly — stdout mode and
--tempmake it easy to chain withcurl, shell scripts, or any Unix pipeline.
| Scenario | Other tools | imgclip |
|---|---|---|
| Screenshot tools (ShareX, Snipaste) | Need a GUI; heavy for quick capture | CLI-native, runs anywhere including SSH / headless |
xclip / pbcopy |
General-purpose, no image watch or auto-save | Purpose-built for clipboard images with --watch mode |
| Custom shell scripts | You maintain edge cases across platforms | Cross-platform, tested on CI (Windows, Linux, macOS) |
Option 1: Download a prebuilt binary (recommended)
- Open the Releases page, pick the latest release, and download an asset from Assets (
imgclip-<target>.zipon Windows,.tar.gzelsewhere). - Choose
<target>for your OS/CPU—e.g.x86_64-pc-windows-msvc,x86_64-unknown-linux-gnu, orx86_64-apple-darwin(most PCs and Intel Macs);aarch64-pc-windows-msvc,aarch64-unknown-linux-gnu, oraarch64-apple-darwinfor ARM Windows, ARM Linux, or Apple Silicon Macs. - Extract to get
imgclip.exeorimgclip; on Linux/macOS runchmod +x imgclipif the file is not executable. - Run it with the full path to the binary, or add its folder to
PATHif you want to typeimgclipfrom any terminal. - Run
imgclip --versionor--helpto verify; if Windows SmartScreen or macOS Gatekeeper blocks it, unblock in Properties or allow under Privacy & Security (macOS:xattr -dr com.apple.quarantine path/to/imgclipif needed).
Option 2: Build from source
Prerequisites: Rust (1.70+)
cargo install --git https://github.com/alexyan0431/imgclip.gitOr build manually:
git clone https://github.com/alexyan0431/imgclip.git
cd imgclip
cargo build --releaseThe binary will be at target/release/imgclip. Copy it somewhere in your $PATH.
Windows users: If you encounter clipboard errors, make sure the terminal session has clipboard access permissions.
cargo install: runcargo uninstall imgclip.- Prebuilt zip/binary or manual copy: delete the executable (find it with
which imgclipon Unix orwhere imgclipon Windows). --installauto-start: runimgclip --uninstallfirst to remove the login startup entry, then remove the binary using either bullet above.
# One-time setup: install auto-start (watches clipboard on every login)
imgclip --installThat's it. After restarting (or logging in), any image you copy or screenshot will be automatically saved to ~/Pictures/imgclip/ (or %USERPROFILE%\Pictures\imgclip\ on Windows).
To remove auto-start later: imgclip --uninstall. To remove imgclip entirely, see Uninstall.
# Start watching (saves to ~/Pictures/imgclip/ by default)
imgclip --watch
# Watch with JPEG output
imgclip --watch -f jpeg -q 90
# Watch with custom directory and poll interval
imgclip --watch --dir ~/screenshots --interval 200
# Run silently in the background
imgclip --watch --quiet# Copy an image (screenshot, browser image, etc.), then:
# Save to a file
imgclip -o screenshot.png
# Save as JPEG with quality 90
imgclip -o photo.jpg -f jpeg -q 90
# Pipe to another command (default outputs PNG to stdout)
imgclip | some-command
# Get a data URI (useful for HTML/CSS embedding)
imgclip --data-uri
# Write to a temp file and print the path
imgclip --temp
# Suppress info messages
imgclip -o out.png --quiet# Watch clipboard and prompt for each new image: [s]ave / [d]iscard / [q]uit
imgclip --interactive
# Interactive with JPEG output
imgclip --interactive -f jpeg -q 90
# Custom save directory
imgclip --interactive --dir ~/screenshots# Copy an image file to the clipboard (supports PNG, JPEG, BMP, WebP, etc.)
imgclip --copy photo.png
imgclip --copy screenshot.jpg| Option | Description |
|---|---|
--watch |
Watch clipboard, auto-save new images |
--interactive |
Watch clipboard, prompt to save or discard each image |
--copy <FILE> |
Copy image file to the clipboard |
--install |
Install auto-start (runs --watch on login) |
--uninstall |
Remove auto-start |
-o, --output <PATH> |
Write image to the specified file |
-f, --format <FORMAT> |
Output format: png (default), jpeg/jpg |
-q, --quality <1-100> |
JPEG quality (default: 85) |
--data-uri |
Output as data:image/...;base64,... string |
--temp |
Write to a temp file, print the path to stdout |
--dir <PATH> |
Save directory for --watch/--interactive (default: ~/Pictures/imgclip) |
--interval <MS> |
Poll interval in ms for --watch/--interactive (default: 500) |
--quiet |
Suppress informational messages |
-h, --help |
Print help |
-V, --version |
Print version |
# Quick screenshot → clipboard → file
imgclip -o shot.png
# Embed image in HTML
echo "<img src=\"$(imgclip --data-uri)\" />"
# Convert clipboard image to JPEG and pipe to curl
imgclip -f jpeg -q 80 | curl -T - https://upload.example.com
# Use in a script to auto-save screenshots
imgclip --temp --quiet | xargs -I{} mv {} ~/screenshots/
# Copy a file to clipboard, then paste into Slack/Docs
imgclip --copy diagram.png
# Selective capture: only save the screenshots you want
imgclip --interactive --dir ~/screenshots- linux.do — Linux & Open Source Community
演示
$ imgclip --watch
imgclip: saved ~/Pictures/imgclip/imgclip-1746359527000-1.png
imgclip: saved ~/Pictures/imgclip/imgclip-1746359595000-2.png
$ imgclip --interactive
imgclip: interactive mode — watching clipboard for changes
[s] save [d] discard [q] quit
imgclip: new image (1920x1080) [s]ave [d]iscard [q]uit? s
imgclip: saved ~/Pictures/imgclip/imgclip-1746359722000-1.png
imgclip: new image (800x600) [s]ave [d]iscard [q]uit? d
imgclip: discarded
工作原理
复制 / 截图 ──▶ 剪贴板 ──▶ imgclip ──▶ 文件 / stdout / data URI
│
┌───────────────┼───────────────┐
│ │ │
单次模式 监听模式 交互模式
(保存一次) (自动保存) (逐张选择保存)
一个轻量级命令行工具,从剪贴板提取图片并保存为文件、输出到 stdout 或转换为 data URI。也支持将图片文件复制到剪贴板。支持监听模式自动保存新图片,以及交互模式让你逐张选择保存或丢弃。
- 零配置开机自启 —
imgclip --install一键设置登录自启,每次开机自动保存剪贴板图片。 - 单文件、零依赖 — 静态编译的 release 产物,无需安装器、无运行时框架,放入 PATH 即可使用。
- 四种模式合一 — 单次捕获、持续监听、交互式选择性保存、文件到剪贴板复制。
- 灵活输出 — 写入文件、管道输出到 stdout、生成
data:image/...URI、创建临时文件并打印路径。 - 跨平台 — 原生支持 Windows、Linux、macOS(x86_64 + ARM)。
- 管道友好 — stdout 模式和
--temp可轻松与curl、Shell 脚本或任何 Unix 管道串联。
| 场景 | 其他工具 | imgclip |
|---|---|---|
| 截图工具(ShareX、Snipaste) | 需要图形界面,快速截图偏重 | CLI 原生,可在 SSH / 无头环境中运行 |
xclip / pbcopy |
通用剪贴板工具,无图片监听和自动保存 | 专为剪贴板图片设计,内置 --watch 模式 |
| 自写 Shell 脚本 | 需自行维护跨平台兼容与边界情况 | 跨平台、CI 测试(Windows、Linux、macOS) |
方式一:下载预编译二进制(推荐)
- 打开 Releases 页面,选择最新版本,在 Assets 中下载对应压缩包(Windows 为
imgclip-<target>.zip,其余平台为.tar.gz)。 - 按系统与 CPU 选择
<target>—常见 PC 与 Intel Mac 用x86_64-pc-windows-msvc、x86_64-unknown-linux-gnu或x86_64-apple-darwin;ARM Windows、ARM Linux 或 Apple Silicon Mac 用aarch64-pc-windows-msvc、aarch64-unknown-linux-gnu或aarch64-apple-darwin。 - 解压得到
imgclip.exe或imgclip;若 Linux/macOS 上无法执行,可执行chmod +x imgclip。 - 使用可执行文件的完整路径运行,或将所在文件夹加入 PATH 以便在终端任意目录输入
imgclip。 - 执行
imgclip --version或--help自检;若遇 Windows SmartScreen 或 macOS 安全拦截,在 属性 中解除锁定或在 隐私与安全性 中允许(macOS 可用xattr -dr com.apple.quarantine path/to/imgclip)。
方式二:从源码构建
前置条件: Rust (1.70+)
cargo install --git https://github.com/alexyan0431/imgclip.git或手动构建:
git clone https://github.com/alexyan0431/imgclip.git
cd imgclip
cargo build --release编译产物在 target/release/imgclip,将其复制到 $PATH 中的目录。
Windows 用户: 如遇剪贴板错误,请确认终端会话拥有剪贴板访问权限。
- 通过
cargo install安装: 执行cargo uninstall imgclip。 - 下载的压缩包或手动拷贝的二进制: 删除该可执行文件(Unix 可用
which imgclip,Windows 可用where imgclip查看路径)。 - 曾执行过
--install: 先运行imgclip --uninstall移除开机自启项,再按上两种方式之一删除程序本体。
# 一次性设置:安装开机自启(登录后自动监听剪贴板)
imgclip --install就这样。重启(或重新登录)后,你复制的任何图片或截图都会自动保存到 ~/Pictures/imgclip/(Windows 为 %USERPROFILE%\Pictures\imgclip\)。
如需移除自启:imgclip --uninstall。若要彻底卸载本工具,见上文 卸载。
# 开始监听(默认保存到 ~/Pictures/imgclip/)
imgclip --watch
# 以 JPEG 格式监听
imgclip --watch -f jpeg -q 90
# 指定保存目录和轮询间隔
imgclip --watch --dir ~/screenshots --interval 200
# 静默后台运行
imgclip --watch --quiet# 先复制一张图片(截图、浏览器图片等),然后:
# 保存到文件
imgclip -o screenshot.png
# 以质量 90 保存为 JPEG
imgclip -o photo.jpg -f jpeg -q 90
# 通过管道传递给其他命令(默认向 stdout 输出 PNG)
imgclip | some-command
# 获取 data URI(用于 HTML/CSS 内嵌)
imgclip --data-uri
# 写入临时文件并打印路径
imgclip --temp
# 静默模式
imgclip -o out.png --quiet# 监听剪贴板,检测到新图片时提示 [s]保存 / [d]丢弃 / [q]退出
imgclip --interactive
# 以 JPEG 格式交互保存
imgclip --interactive -f jpeg -q 90
# 自定义保存目录
imgclip --interactive --dir ~/screenshots# 将图片文件复制到剪贴板(支持 PNG、JPEG、BMP、WebP 等格式)
imgclip --copy photo.png
imgclip --copy screenshot.jpg| 选项 | 说明 |
|---|---|
--watch |
监听剪贴板,自动保存新图片 |
--interactive |
监听剪贴板,逐张选择保存或丢弃 |
--copy <FILE> |
将图片文件复制到剪贴板 |
--install |
安装开机自启(登录时运行 --watch) |
--uninstall |
移除开机自启 |
-o, --output <PATH> |
将图片保存到指定文件 |
-f, --format <FORMAT> |
输出格式:png(默认)、jpeg/jpg |
-q, --quality <1-100> |
JPEG 质量(默认 85) |
--data-uri |
输出为 data:image/...;base64,... 字符串 |
--temp |
写入临时文件,将路径打印到 stdout |
--dir <PATH> |
--watch/--interactive 保存目录(默认 ~/Pictures/imgclip) |
--interval <MS> |
--watch/--interactive 轮询间隔(毫秒,默认 500) |
--quiet |
静默信息输出 |
-h, --help |
显示帮助 |
-V, --version |
显示版本 |
# 快速截图 → 剪贴板 → 文件
imgclip -o shot.png
# 在 HTML 中内嵌图片
echo "<img src=\"$(imgclip --data-uri)\" />"
# 将剪贴板图片转为 JPEG 并通过 curl 上传
imgclip -f jpeg -q 80 | curl -T - https://upload.example.com
# 在脚本中自动保存截图
imgclip --temp --quiet | xargs -I{} mv {} ~/screenshots/
# 复制文件到剪贴板,然后粘贴到 Slack/文档
imgclip --copy diagram.png
# 选择性截图:只保存想要的截图
imgclip --interactive --dir ~/screenshots- linux.do — Linux 与开源技术社区
