Last active
February 11, 2022 10:05
-
-
Save shevchenkoartem/90a919433ad1115344d5485a9a8f7aa8 to your computer and use it in GitHub Desktop.
Converts an image (e.g. PNG) to an ICNS icon-file. Inspired by https://stackoverflow.com/a/20703594
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/sh -e | |
######################################### | |
# Usage: | |
######################################### | |
# for each png file in the directory: | |
# sh make-icns.sh | |
######################################### | |
# for a specific file: | |
# sh make-icns.sh filename.ext | |
######################################### | |
trap somethingFailed ERR | |
function somethingFailed() { | |
echo "Something has failed. The job has bot been completed." | |
exit 1 | |
} | |
if [ $# -eq 0 ] | |
then | |
echo "Running script for each PNG file in the current directory..." | |
for f in *.png ; do sh $0 "$f" ; done | |
exit; | |
fi | |
mkdir $1.iconset | |
sips -z 16 16 $1 --out $1.iconset/icon_16x16.png | |
sips -z 32 32 $1 --out $1.iconset/[email protected] | |
sips -z 32 32 $1 --out $1.iconset/icon_32x32.png | |
sips -z 64 64 $1 --out $1.iconset/[email protected] | |
sips -z 128 128 $1 --out $1.iconset/icon_128x128.png | |
sips -z 256 256 $1 --out $1.iconset/[email protected] | |
sips -z 256 256 $1 --out $1.iconset/icon_256x256.png | |
sips -z 512 512 $1 --out $1.iconset/[email protected] | |
sips -z 512 512 $1 --out $1.iconset/icon_512x512.png | |
cp $1 $1.iconset/[email protected] | |
iconutil -c icns $1.iconset | |
rm -R $1.iconset | |
echo "$1.icns is ready!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment