Adjust darwin build configuration to new project structure.
This commit is contained in:
76
platform-darwin/Scripts/convertImages
Executable file
76
platform-darwin/Scripts/convertImages
Executable file
@@ -0,0 +1,76 @@
|
||||
#! /usr/bin/env bash
|
||||
source bashlib
|
||||
cd "${0%/*}/../Resources/Media"
|
||||
PATH+=:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
|
||||
temp="${TMPDIR:-/tmp}/.$$.convertImages"
|
||||
mkdir "$temp" || err "Couldn't create temp directory." || return
|
||||
trap 'rmdir "$temp"' EXIT
|
||||
|
||||
downsize() {
|
||||
local from=$1 to=$2 size=${3:-50%}
|
||||
convert "$from" -filter box -resize "$size" -unsharp 1x1+1+0.4 "$to"
|
||||
pngcrush -d "$temp" -rem gAMA -rem cHRM -rem sRGB -rem iCCP "$to" && mv "$temp/"* "$to"
|
||||
}
|
||||
|
||||
|
||||
|
||||
inf "Converting appiconsets"
|
||||
declare -A icons=(
|
||||
["ios-Icon-60@2x.png"]=120
|
||||
["ios-Icon-40@2x.png"]=80
|
||||
["ios-Icon-40~ipad.png"]=40
|
||||
["ios-Icon-40~ipad@2x.png"]=80
|
||||
["ios-Icon-Small@2x.png"]=58
|
||||
["ios-Icon-Small~ipad.png"]=29
|
||||
["ios-Icon-Small~ipad@2x.png"]=58
|
||||
["ios-Icon-76~ipad.png"]=76
|
||||
["ios-Icon-76~ipad@2x.png"]=152
|
||||
["mac-icon_512x512.png"]=512
|
||||
["mac-icon_512x512@2x.png"]=1024
|
||||
["mac-icon_256x256@2x.png"]=512
|
||||
["mac-icon_256x256.png"]=256
|
||||
["mac-icon_128x128@2x.png"]=256
|
||||
["mac-icon_128x128.png"]=128
|
||||
["mac-icon_32x32@2x.png"]=64
|
||||
["mac-icon_32x32.png"]=32
|
||||
["mac-icon_16x16@2x.png"]=32
|
||||
["mac-icon_16x16.png"]=16
|
||||
)
|
||||
for name in "${!icons[@]}"; do
|
||||
size=${icons[$name]}
|
||||
source=${name%%-*}-icon@2x.png
|
||||
file=Images.xcassets/AppIcon.appiconset/${name#*-}
|
||||
echo "$PWD/$file"
|
||||
|
||||
if [[ $source -nt $file ]]; then
|
||||
pinf "$file ($size px)"
|
||||
downsize "$source" "$file" "${size}x${size}"
|
||||
fnip
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
hr
|
||||
inf "Converting @2x/-hd artwork"
|
||||
for file in ./**/*{@2x,-ipadhd,-hd}.png; do
|
||||
inArray "${file##*/}" "${icons[@]}" && continue
|
||||
[[ ! -e $file ]] && continue
|
||||
|
||||
dest=${file/@(@2x|-hd)}
|
||||
dest=${dest/-ipadhd/-ipad}
|
||||
|
||||
if [[ $file = Default* ]]; then
|
||||
read width height < <(identify -format '%w %h' "$file")
|
||||
if (( width > height )); then
|
||||
emit "Rotating $file" --
|
||||
mogrify -rotate 90 "$file"
|
||||
emit -$?
|
||||
fi
|
||||
fi
|
||||
if [[ ! -e $dest || "$dest" -ot "$file" ]]; then
|
||||
pinf "$file -> $dest"
|
||||
downsize "$file" "$dest"
|
||||
fnip
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user