Skip to content

paulsmith/pbimg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pbimg - Clipboard image saver

CI

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.

How it works

It saves the clipboard image to a specified file path, or to stdout if it is redirected.

Requirements

  • macOS
  • Xcode Command Line Tools

Installation

  1. Clone the repository or download the source code.
  2. 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

Usage

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]

Example

For example, use the screenshot utility to copy a screenshot to the clipboard: 4

pbimg output.png
pbimg-example.mov

Convert format

With ImageMagick (or GraphicsMagick) installed, convert between formats with a pipeline:

pbimg | convert - output.gif
pbimg | convert - -quality 65 output.jpg

Resize

pbimg | convert - -resize 25% thumbnail.png

Get info about image on pasteboard

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

Upload to web service

pbimg | curl --data-binary @- https://example.com/upload

Acknowledgements

Simon Willison for the idea.

License

This project is licensed under the MIT No Attribution License.