Automatically resize screenshots to 50% on retina Macs with Automator

If you're like me and you often need to send some screenshots by e-mail but you don't want to send @2x retina images to them you can use this Automator Folder Action to automatically resize them.

By default all screenshots are saved on your Desktop, to keep things cleaner you could set custom folder for your screenshots. First you create the folder in Finder (my example uses folder named Screenhots inside Pictures folder).
Then open terminal and type something like this:

defaults write com.apple.screencapture location ~/Pictures/Screenshots

Now open Automator, create new Folder Action. 

Click on "Choose folder" and select yout Screenshots folder.

Now add "Run Shell Script" action. And that's the only action you'll need. Your Shell Script should look like this:

 

#!/bin/bash
DPI=$(sips -g dpiHeight "$1")
if [[ "$DPI" =~ 144.00 ]]; then
    H=$(sips -g pixelHeight "$1" | grep 'pixelHeight' | cut -d: -f2)
    NEWH=$(($H / 2))
    sips --resampleHeight "$NEWH" -s dpiHeight 72.0 -s dpiWidth 72.0 "$1" >/dev/null
fi

And that's about it. What this script does is that it's checking if the newly added file to your screenshot is 144 DPI (@2x retina) if it is then it gets the image height divides it by 2 and resizes it to the new dimensions while also setting DPI to 72.

 

Comments

Hello,
I'm finding that this script only works randomly. I took five screenshots and only 2 of them resized. Did I miss something?

Beth 22. Mar 2015 at 10:48 PM

Leave a comment

*
Leave your e-mail if you would like to get reply from me. Your e-mail will not be shown on my web page nor will I use it for anything other than replying to your question/comment.