Created
January 2, 2012 13:47
-
-
Save puppybits/1550741 to your computer and use it in GitHub Desktop.
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
function halfPNGs(){ | |
dir=$1 | |
n=0 | |
while read f | |
do | |
# Image name | |
i=$(basename "$f") | |
if [[ $i == *\@2x\.png ]]; then | |
# Height of image | |
h=$(sips -g pixelHeight $f) | |
# Cut off all but the numbers | |
h=${h#*:} | |
# Width of image | |
w=$(sips -g pixelWidth $f) | |
# Cut off all but the numbers | |
w=${w#*:} | |
# Resize the png and output in the same folder with @2x cut off | |
sips -s format png -z $(expr $h / 2) $(expr $w / 2) $f --out ${f%@*}\.png | |
fi | |
done < <(find $dir -iname *.png) # Find all pngs in directory | |
} | |
# Example usage | |
# halfPNGs ~/Desktop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment