Last active
November 21, 2024 09:11
-
-
Save pd95/f8afdeb6139d96019bd60b11a70d6367 to your computer and use it in GitHub Desktop.
A ZSH command file to produce the various PNG files required for iOS and macOS app Icons using `sips` (scriptable image processing system) available on any macOS. The resulting PNGs in the "AppIcons" folder can then be dragged into Xcode's `Assets.xcassets` onto a placeholder for an AppIcon.
This file contains hidden or 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/zsh | |
# Shell Script to create all relevant icons from an high resolution artwork | |
if [ "x$1" != "x" -a -f "$1" ] ; then | |
INPUT=$1 | |
else | |
INPUT="Artwork.png" | |
fi | |
if [ ! -f "$INPUT" ]; then | |
echo "Input file not specified" | |
exit 1 | |
fi | |
mkdir -p AppIcons | |
while IFS= read -r line ; do | |
FILENAME=${line% *} | |
SIZE=${line#* } | |
if [ "x$FILENAME" != "x" ] ; then | |
COMMAND="sips -s format png \"$INPUT\" --resampleHeightWidth $SIZE $SIZE --out \"AppIcons/$FILENAME\"" | |
echo "$COMMAND" | |
eval "$COMMAND" | |
else | |
echo "" | |
fi | |
done <<EOF | |
[email protected] 40 | |
[email protected] 60 | |
[email protected] 29 | |
[email protected] 58 | |
[email protected] 87 | |
[email protected] 80 | |
[email protected] 120 | |
[email protected] 57 | |
[email protected] 114 | |
[email protected] 120 | |
[email protected] 180 | |
[email protected] 20 | |
[email protected] 40 | |
[email protected] 29 | |
[email protected] 58 | |
[email protected] 40 | |
[email protected] 80 | |
[email protected] 76 | |
[email protected] 152 | |
[email protected] 167 | |
[email protected] 1024 | |
[email protected] 16 | |
[email protected] 32 | |
[email protected] 32 | |
[email protected] 64 | |
[email protected] 128 | |
[email protected] 256 | |
[email protected] 256 | |
[email protected] 512 | |
[email protected] 512 | |
[email protected] 1024 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, I thought the pixels where shifting from he resampling algorithm used in your script. I checked my 1024pt icon that I ran the script on and the text is actually off center. Thanks.