Last active
August 29, 2015 14:11
-
-
Save Jeswang/04ea64f4708e476c5670 to your computer and use it in GitHub Desktop.
Transform images
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
function halfPNGs(){ | |
dir=$1 | |
n=0 | |
while read f | |
do | |
# Image name | |
i=$(basename "$f") | |
echo $i | |
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 '*@2x.png') # Find all pngs in directory | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment