Created
June 10, 2014 08:56
-
-
Save sirkkalap/c740fb287b701c8565f0 to your computer and use it in GitHub Desktop.
Screenshot in scale 50% (for Retina)
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="/Users/petrisi/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 | |
DATE=$(date +%Y-%m-%d) | |
TIME=$(date +%H.%M.%S) | |
NOW="" | |
SS_BASENAME="$SS_PATH/Näyttökuva $DATE kello $TIME" | |
# execute screen capture command, screenshot$NOW.png is the name of file | |
screencapture -i -r "$SS_BASENAME@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_BASENAME@2X.png" ]; then | |
# get the 50% width of screenshot by sips | |
WIDTH=$(($(sips -g pixelWidth "$SS_BASENAME@2X.png" | cut -s -d ':' -f 2 | cut -c 2-)/2)) | |
# scale down by sips | |
sips --resampleWidth $WIDTH "$SS_BASENAME@2X.png" --out "$SS_BASENAME.png" | |
# copy small one to clipboard by applescript | |
osascript -e "set the clipboard to POSIX file \"$SS_BASENAME.png\"" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment