Created
June 8, 2014 12:10
-
-
Save tuhaihe/0bb13ec1b6a2710b360a to your computer and use it in GitHub Desktop.
Macbook-Retina-Screenshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the path where screenshots to save | |
SS_PATH="/Users/wangdj/Desktop" | |
# if you want to save them to your desktop, SS_PATH should be "/Users/YOURNAME/Desktop" | |
# a variable of unix timestamp for screenshot file name | |
NOW=$(date +%s) | |
# execute screen capture command, screenshot$NOW.png is the name of file | |
screencapture -i -r $SS_PATH/[email protected] | |
# then downscale the high resolution screenshot to 50% by imagemagick | |
# /usr/local/bin/convert $SS_PATH/[email protected] -resize 50% $SS_PATH/[email protected] | |
# check if screenshot is existing | |
if [ -f $SS_PATH/[email protected] ]; then | |
# get the 50% width of screenshot by sips | |
WIDTH=$(($(sips -g pixelWidth $SS_PATH/[email protected] | cut -s -d ':' -f 2 | cut -c 2-)/2)) | |
# scale down by sips | |
sips --resampleWidth $WIDTH $SS_PATH/[email protected] --out $SS_PATH/[email protected] | |
# rm orginal pic file | |
rm $SS_PATH/[email protected] | |
# copy small one to clipboard by applescript | |
osascript -e 'set the clipboard to POSIX file "'$SS_PATH/[email protected]'"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment