-
-
Save matthewpenkala/d08f6e527af6d3ec2fb38cbb383f42ed to your computer and use it in GitHub Desktop.
Convert SVG file to macOS icon (icns) format
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
#!/bin/sh -x | |
set -e | |
SIZES=" | |
16,16x16 | |
32,32x32 | |
64,64x64 | |
128,128x128 | |
256,256x256 | |
512,512x512 | |
32,16x16@2x | |
64,32x32@2x | |
128,64x64@2x | |
256,128x128@2x | |
512,256x256@2x | |
1024,512x512@2x | |
" | |
for SVG in "$@"; do | |
BASE=$(basename "$SVG" | sed 's/\.[^\.]*$//') | |
ICONSET="$BASE.iconset" | |
mkdir -p "$ICONSET" | |
for PARAMS in $SIZES; do | |
SIZE=$(echo $PARAMS | cut -d, -f1) | |
LABEL=$(echo $PARAMS | cut -d, -f2) | |
svg2png -w $SIZE -h $SIZE "$SVG" "$ICONSET"/icon_$LABEL.png | |
done | |
iconutil -c icns "$ICONSET" | |
rm -rf "$ICONSET" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment