1

I often want to add a drop shadow to images in my clipboard (like when using ⌃ ⇧ ⌘ + 4). For the macOS built-in capture utility I can add a dropshadow when capturing the whole window by hitting the spacebar. enter image description here However, if I use the cross-hairs to make a smaller selection, then I don't get the dropshadow.

enter image description here

The dropshadow is really useful for me because it sets off the edge of the screenshot, making it stand out against the white backgrounds where I'm usually pasting it. So far I've been resolving this manually by pasting the screenshot into my image editor and manually adding the dropshadow, but I'm lazy and I'm tired of doing this manually.

How can I automatically add a dropshadow to the image in the clipboard?

1 Answer 1

2

So far I've found the following to be the most painless and automatic approach (although it does require a few minutes of initial setup):

  1. Write an Automator Service that:
  • Saves the clipboard to file
  • Uses ImageMagick to add the drop shadow
  • Copy the new image back to the clipboard
  1. Create a new keyboard shortcut that calls said ^ Automator Service

So here's how to set it up step-by-step.

Prerequisites

brew dependencies

Install pngpaste, which can save the clipboard to file, and ImageMagick (convert) for adding the dropshadow.

brew install pngpaste imagemagick

Manual impbcopy compilation

impbcopy is an informal tool that can copy an image file to the clipboard. It is available from this GitHub gist. Follow the instructions there to install the tool.

You simply compile it with: gcc -Wall -g -O3 -ObjC -framework Foundation -framework AppKit -o impbcopy impbcopy.m

Create the Automator Service

  1. Open Automator, and create a Quick Action enter image description here
  2. Search for the Run Shell Script action, and drag it to the right. Select Workflow receives no input. enter image description here

Paste in these contents, making sure to set the path to wherever you installed impbcopy (I personally put it in ~/bin):

/opt/homebrew/bin/pngpaste /tmp/to-add-dropshadow.png
/opt/homebrew/bin/convert /tmp/to-add-dropshadow.png \( +clone -background transparent -shadow 30x15+10+10 \) +swap -background transparent -layers merge +repage /tmp/has-drop-shadow.png 2>/dev/null
/PATH/WHERE/YOU/INSTALLED/impbcopy /tmp/has-drop-shadow.png
  1. (Optional) Tweak 30x15+10+10 to modify the dropshadow's size and transparency. The format is opacity x blur_strength + horizontal_distance + vertical_distance (documented here).

  2. Save the shortcut as "Add Dropshadow To Clipboard Image"

  3. Finally, assign it a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services > General > Add Dropshadow To Clipboard Image. Since I commonly use this in conjuction with the standard clipboard shortcut, I find it convenient to use ⌃ ⇧ ⌘ + 5 but it's up to you.

enter image description here

Now it's really simple to add a dropshadow to any image on the clipboard! Here's a dropshadow'd screenshot I just took now by simply doing:

  1. ⌃ ⇧ ⌘ + 4 (take screenshot with macOS built-in screenshot utility via crosshairs)
  2. ⌃ ⇧ ⌘ + 5 (trigger our new dropshadow Automator service)
  3. ⌘ + V (paste!)

enter image description here

2
  • 1
    I love 'professional idleness'. Spend several hours figuring out how to do a task now so that you'll never have to faff with the components of it ever again. :))
    – Tetsujin
    Commented Aug 12, 2022 at 18:48
  • 1
    LOL right? I think today I finally hit the threshold where I've wasted more minutes manually adding dropshadows for internal documentation at work than it would take to come up with the above process and write it down so I never forget it again. This post is more a love-letter to my future self than anything because I know I'll want to set this up again on another workstation in the future.
    – Cory Klein
    Commented Aug 12, 2022 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .