Created
February 6, 2013 15:34
-
-
Save jeremiegirault/4723317 to your computer and use it in GitHub Desktop.
Downscale retina images to non-retina. Usefull for adding a build phase to xcode.
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
#!/bin/bash | |
# Downsamples all retina ...@2x.png images. | |
echo "Downsampling retina images..." | |
dir=$(pwd) | |
find "$dir" -name "*@2x.png" | while read image; do | |
outfile=$(dirname "$image")/$(basename "$image" @2x.png).png | |
if [ "$image" -nt "$outfile" ]; then | |
basename "$outfile" | |
width=$(sips -g "pixelWidth" "$image" | awk 'FNR>1 {print $2}') | |
height=$(sips -g "pixelHeight" "$image" | awk 'FNR>1 {print $2}') | |
sips -z $(($height / 2)) $(($width / 2)) "$image" --out "$outfile" | |
test "$outfile" -nt "$image" || exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment