Created
April 15, 2015 02:43
-
-
Save sorrycc/c784f752add70169f4ae to your computer and use it in GitHub Desktop.
This file contains 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="/tmp" | |
# 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/screenshot$NOW@2X.png | |
# then downscale the high resolution screenshot to 50% by imagemagick | |
# /usr/local/bin/convert $SS_PATH/screenshot$NOW@2X.png -resize 50% $SS_PATH/screenshot$NOW@1X.png | |
# check if screenshot is existing | |
if [ -f $SS_PATH/screenshot$NOW@2X.png ]; then | |
# get the 50% width of screenshot by sips | |
WIDTH=$(($(sips -g pixelWidth $SS_PATH/screenshot$NOW@2X.png | cut -s -d ':' -f 2 | cut -c 2-)/2)) | |
# scale down by sips | |
sips --resampleWidth $WIDTH $SS_PATH/screenshot$NOW@2X.png --out $SS_PATH/screenshot$NOW@1X.png | |
# rm orginal pic file | |
rm $SS_PATH/screenshot$NOW@2X.png | |
# copy small one to clipboard by applescript | |
osascript -e 'set the clipboard to POSIX file "'$SS_PATH/screenshot$NOW@1X.png'"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment