Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created June 1, 2012 18:06
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielpunkass/2854083 to your computer and use it in GitHub Desktop.
Save danielpunkass/2854083 to your computer and use it in GitHub Desktop.
Zsh functions for easily "fixing" iOS-optimized PNG files
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