A command-line application for macOS that saves the clipboard image to a file or
outputs the raw bytes to stdout. It works similarly to pbpaste
, but that utility
is limited to textual data.
It saves the clipboard image to a specified file path, or to stdout if it is redirected.
- macOS
- Xcode Command Line Tools
- Clone the repository or download the source code.
- Compile the Swift code using the following command:
swift build
Then copy the build artifact ./.build/arm64-apple-macosx/debug/pbimg
to your
$PATH.
Example:
install -m 0755 ./.build/arm64-apple-macosx/debug/pbimg $HOME/.local/bin
To save the clipboard image to a file:
pbimg <file_path>
To output the raw bytes of the clipboard image to stdout:
pbimg > <file_path>
To force output the raw bytes to stdout even if stdout is a terminal. Note that this might cause your terminal to enter an odd state.
pbimg [-f | --force]
For example, use the screenshot utility to copy a screenshot to the clipboard:
⌘
+⌃
+⇧
+4
pbimg output.png
pbimg-example.mov
With ImageMagick (or GraphicsMagick) installed, convert between formats with a pipeline:
pbimg | convert - output.gif
pbimg | convert - -quality 65 output.jpg
pbimg | convert - -resize 25% thumbnail.png
pbimg | identify -
-=>/var/folders/mc/p59f_1dd1w9b9tfc1zc6f1gr0000gn/T/magick-7LMqLeLrxmEOVvX3zBqn_VF8y2ouyaVO PNG 3248x2080 3248x2080+0+0 8-bit sRGB 970964B 0.010u 0:00.000
pbimg | curl --data-binary @- https://example.com/upload
Simon Willison for the idea.
This project is licensed under the MIT No Attribution License.