Line | |
---|
1 | #! /bin/bash |
---|
2 | # Based on <http://stackoverflow.com/a/23688878/393146> and |
---|
3 | # <http://stackoverflow.com/a/11788723/393146>. |
---|
4 | # converts the passed-in svgs to icns format |
---|
5 | |
---|
6 | if [[ "$#" -eq 0 ]]; then |
---|
7 | echo "Usage: $0 svg1 [svg2 [...]]" |
---|
8 | exit 0 |
---|
9 | fi |
---|
10 | |
---|
11 | temp="$(pwd)/temp" |
---|
12 | declare -a res=(16 32 64 128 256 512 1024) |
---|
13 | for f in "$*"; do |
---|
14 | name="`basename -s .svg "$f"`" |
---|
15 | iconset="$temp/${name}.iconset" |
---|
16 | mkdir -p "$iconset" |
---|
17 | for r in "${res[@]}"; do |
---|
18 | inkscape -z -e "$iconset/icon_${r}x${r}.png" -w "$r" -h "$r" "$f" |
---|
19 | done |
---|
20 | ln "$iconset/icon_32x32.png" "$iconset/icon_16x16@2x.png" |
---|
21 | mv "$iconset/icon_64x64.png" "$iconset/icon_32x32@2x.png" |
---|
22 | ln "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png" |
---|
23 | ln "$iconset/icon_512x512.png" "$iconset/icon_256x256@2x.png" |
---|
24 | mv "$iconset/icon_1024x1024.png" "$iconset/icon_512x512@2x.png" |
---|
25 | iconutil -c icns -o "${name}.icns" "$iconset" |
---|
26 | done |
---|
27 | rm -rf "$temp" |
---|
Note: See
TracBrowser
for help on using the repository browser.