Created
June 1, 2012 18:06
-
-
Save danielpunkass/2854083 to your computer and use it in GitHub Desktop.
Zsh functions for easily "fixing" iOS-optimized PNG files
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 fixpng () | |
{ | |
if [[ ! -f $1 ]] ; then | |
echo "Usage: fixpng <inputFiles> [outputFile]" | |
return -1 | |
else | |
local inputFile=$1 | |
local outputFile=$1 | |
if [[ -e $2 ]] ; then | |
outputFile=$2 | |
else | |
zmodload zsh/regex | |
local baseName=$1 | |
[[ $inputFile -regex-match "^(.*).png" ]] && baseName=$match[1] | |
outputFile=$baseName-fixed.png | |
fi | |
echo Writing fixed PNG to $outputFile | |
"`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush" -q -revert-iphone-optimizations $inputFile $outputFile | |
fi | |
} | |
# Fix a whole mess of pngs at once | |
fixpngs () | |
{ | |
if [[ ! -f $1 ]] ; then | |
echo "Usage: fixpng <inputFiles> [outputFile]" | |
return -1 | |
else | |
for i in "$@"; do fixpng ./"$i"; done; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment