DEV Community

Cover image for Imgclip: A Cross-Platform CLI for Clipboard ↔ Image File Conversion
Alex YAN
Alex YAN

Posted on

Imgclip: A Cross-Platform CLI for Clipboard ↔ Image File Conversion

You take a screenshot. You mean to paste it somewhere. You get distracted. The next copy overwrites your clipboard, and the screenshot is gone forever.

That kept happening to me — especially on Linux, where there's no built-in "screenshot → file" flow like macOS. So I built imgclip.

What it does

Imgclip is a single-binary CLI that moves images between your clipboard and files. Four modes, one tool:

# Save clipboard image to a file
imgclip -o screenshot.png

# Watch clipboard, auto-save every new image
imgclip --watch

# Watch clipboard, but choose which ones to keep
imgclip --interactive

# Copy an image file back to clipboard (for pasting into Slack, docs, etc.)
imgclip --copy diagram.png
Enter fullscreen mode Exit fullscreen mode

imgclip demo

Why not just use...

ShareX / Snipaste? Great GUI tools, but they need a desktop. Imgclip works over SSH, in headless environments, and in shell scripts.

xclip -selection clipboard -t image/png -o > file.png? That works for one-shot saves, but it's a pain to remember — and it doesn't do watch mode, interactive filtering, or auto-start.

A shell script? I tried. Handling clipboard APIs across Windows, Linux, and macOS gets ugly fast. Imgclip wraps arboard for cross-platform clipboard access and handles the edge cases.

A few things I found useful

Auto-start on login:

imgclip --install
Enter fullscreen mode Exit fullscreen mode

Sets up platform-native auto-start (VBS on Windows, .desktop on Linux, LaunchAgent on macOS). Every screenshot gets saved automatically.

Pipeline-friendly output:

# Get a data URI for HTML embedding
imgclip --data-uri

# Write to temp file and print the path (great for scripts)
imgclip --temp

# Pipe JPEG to another command
imgclip -f jpeg -q 80 | curl -T - https://upload.example.com
Enter fullscreen mode Exit fullscreen mode

Interactive mode for selective capture:

When you're taking lots of screenshots but only want to keep some of them:

$ 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
Enter fullscreen mode Exit fullscreen mode

Install

Download a prebuilt binary from GitHub Releases (6 targets: x86_64 + aarch64 for Windows/Linux/macOS), or build from source:

cargo install --git https://github.com/alexyan0431/imgclip.git
Enter fullscreen mode Exit fullscreen mode

Single binary, no runtime dependencies. Drop it in your PATH and you're done.


Imgclip is MIT-licensed and written in Rust. Feedback and contributions welcome — especially around new output formats, platform-specific quirks, or package manager recipes (Homebrew, scoop, AUR).

Star on GitHub

Top comments (0)