Forget the complex or manual steps, or costly tools to get screen shots scaled down from a retina display. I have a shell script that triggers an interactive window screen capture, saves the screen shot (assumed to be 2x retina display), re-sizes it to 1x and compresses the PNG further! Best of all, it does not require paid software or Automator.
First off, some assumptions:
- Only saves in PNG format.
- Requires ImageOptim to be installed in Applications.
- Must be run on a retina display at "default" resolution.
The last point is important because the script assumes the retina screen shot is 2x resolution. To make sure, check your Display Settings. Resolution should be
Default for display and not
To cut to the chase, here is the script:
#!/bin/bash if [ -z "$1" ] then out=screenshot`date "+%s"` else out=$1 fi screencapture -Wox $firstname.lastname@example.org if [ -f $email@example.com ]; then width=$(($(sips -g pixelWidth $firstname.lastname@example.org | cut -s -d ':' -f 2 | cut -c 2-)/2)) sips -Z $width $email@example.com --out $firstname.lastname@example.org open -a ImageOptim $out@?x.png fi
And a bit of explanation:
- Check to see if a command line argument is provided - this should be the screen shot file name.
- If not, save to a file prefixed by
screenshotfollowed by numbers (Epoch time, but who cares).
- Trigger the screen capture, by default on Window mode (press spacebar to toggle) and save it as the file name that ends with @2x.png. Yes, the script only supports PNG.
- If the file was successfully saved, then
- Get the width and divide it by 2.
- Open the images in ImageOptim, which automatically starts the compression process.
If you don't want to see the ImageOptim user interface, you could replace the line with
On my machine, I put the script in my home directory as screencapture.sh. Do
chmod +x screenscapture.sh, and invoke it from Terminal via
~/screencapture output_image. If you want to put it on the Desktop, with the intention of double clicking to run it, then rename the extension from
Back to the issue around Display scaling, here are the resolutions captured on my 13" MacBook Pro with retina:
|Display Scaling||Resolution||Scale Factor|
|Default (native resolution)||2560x1600||1.000|
This differs on all Macs, e.g. 15" MacBook Pro with retina has a native resolution of 2880x1800 (both the 13" and 15" have 16:10 aspect ratios).
BTW, to change the way the standard Command-Shift-4 screenshot is captured - disable shadow, change save location and file name respectively:
defaults write com.apple.screencapture disable-shadow -bool true defaults write com.apple.screencapture location ~/Desktop/Screenshots defaults write com.apple.screencapture name "Screen" killall SystemUIServer