Skip to content

Instantly share code, notes, and snippets.

@halivert
Created September 21, 2018 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halivert/32650fcbc9f4b12cfabc94cdb4a32eed to your computer and use it in GitHub Desktop.
Save halivert/32650fcbc9f4b12cfabc94cdb4a32eed to your computer and use it in GitHub Desktop.
Iconos para iOS
if [ $# -eq 0 ]
then
echo "No arguments"
exit
fi
for file in "$@"
do
fullFileName=$file
extension="${fullFileName##*.}"
fileName="${fullFileName%.*}"
height=$(sips -g pixelHeight $fullFileName | tail -n1 | cut -d" " -f4)
width=$(sips -g pixelWidth $fullFileName | tail -n1 | cut -d" " -f4)
maxDim=$(( $height > $width ? $height : $width ))
r1x="$fileName@1x.$extension"
r2x="$fileName@2x.$extension"
r3x="$fileName@3x.$extension"
tee $r1x $r2x $r3x < $fullFileName > /dev/null
sips -Z $(echo "scale=3; $maxDim / 3" | bc -l) $r1x > /dev/null
sips -Z $(echo "scale=3; $maxDim * 2 / 3" | bc -l) $r2x > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment