--- /dev/null
+#!/usr/bin/env bash
+
+# given a list of differently sized png files with the size in the filename like this:
+# myiconfile-16.png myiconfile-32.png myiconfile-48.png myiconfile-64.png myiconfile-128.png myiconfile-256.png myiconfile-512.png
+# run
+# create_iconfiles.sh myiconfile-*.png
+# to create an ICO file (for Windows) myiconfile.ico and an ICNS file (for macOS) myiconfile.icns
+
+BASENAME=${1%-*}
+if [ x$BASENAME = x ]; then
+ echo "Could not calculate basename from '${1}'"
+ exit 1
+fi
+
+ICOFILE=${BASENAME}.ico
+echo "Creating ${ICOFILE}"
+convert $* ${ICOFILE}
+
+ICNSFILE=${BASENAME}.icns
+echo "Creating ${ICNSFILE}"
+# dont' include 64x64 icon (for some reason they're not allowed in icns file)
+ICNSARGS=""
+for ARG in $*; do
+ NUM=${ARG##*-}
+ NUM=${NUM%px*}
+ NUM=${NUM%x*}
+ NUM=${NUM%.*}
+ if [ x$NUM != x64 -a x$NUM != x38 ]; then
+ ICNSARGS="${ICNSARGS} $ARG"
+ fi
+done
+png2icns ${ICNSFILE} ${ICNSARGS}