Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 41 lines (35 sloc) 0.919 kB
e8f095f @atomicbird Add fixpng.sh for convenient fixing of iOS-optimized PNGs.
authored
1 # Fix an iOS-converted PNG
2 # By Tom Harrington, June 1 2012.
3
4 fixpng () {
5 if [ -z "$1" ]; then
6 echo "Usage: fixpng <inputFile> [outputFile]"
7 return -1
8 else
9 inputFile=$1
10
11 # Only "png" and "PNG" are allowed
12 pngRegex='.*.(png|PNG)$'
13 if [[ $inputFile =~ $pngRegex ]]; then
14 if [ -n "$2" ]; then
15 # Use whatever name was provided
16 outputFile=$2
17 else
18 # Generate a filename, preserve file extension case.
19 extension=${BASH_REMATCH[1]}
20 outputFile=${inputFile%.$extension}-fixed.$extension
21 fi
22 echo "Converting $inputFile to $outputFile"
23
24 xcrun -sdk iphoneos pngcrush -q -revert-iphone-optimizations $inputFile $outputFile
25 else
26 echo "Skipping $inputFile since it's not a png"
27 fi
28 fi
29 }
30
31 # Fix a whole mess of pngs at once
32 fixpngs () {
33 if [ -z "$1" ]; then
34 echo "Usage: fixpng <inputFiles> [outputFile]"
35 return -1
36 else
37 for file in "$@"; do fixpng $file; done
38 fi
39
40 }
Something went wrong with that request. Please try again.