X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fmk_jalview_icons.sh;fp=utils%2Fmk_jalview_icons.sh;h=4a2768e691e7a712c905226896b5daed07de1e4c;hb=3efc24bc7b7855ff135fa96e35ab1004eaeb4f5e;hp=0000000000000000000000000000000000000000;hpb=dae56c38c3f14e96308540c30f35ca8f1d917edf;p=jalview.git diff --git a/utils/mk_jalview_icons.sh b/utils/mk_jalview_icons.sh new file mode 100755 index 0000000..4a2768e --- /dev/null +++ b/utils/mk_jalview_icons.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +FILENAME512=$1 +BASENAME=${FILENAME512%-512.png} + +usage () { + echo "$(basename "$0") -512.png" +} + +[ "$1" = "-h" ] && usage && exit 0 +[ -r "$FILENAME512" ] || ( usage && echo "'${FILENAME512}' must exist and be readable" && exit 1 ) +[ "$BASENAME" = "$FILENAME512" ] && usage && echo "Must have '-512.png' at end of filename" && exit 2 + +set -e + +SIZES="16 32 38 48 64 128 256" +declare -a ICOFILES=() +declare -a ICNSFILES=() +for n in $SIZES +do + NEWFILE="${BASENAME}-${n}.png" + [ -e "{$NEWFILE}" ] && continue + convert -geometry "${n}x${n}" "${BASENAME}-512.png" "${NEWFILE}" + [ "${n}" != 38 ] && ICOFILES=( "${ICOFILES[@]}" "${NEWFILE}" ) + [ "${n}" != 64 ] && [ "${n}" != 38 ] && ICNSFILES=( "${ICNSFILES[@]}" "${NEWFILE}" ) +done + +# make the .ico +ICOFILE="${BASENAME}.ico" +echo "Creating ${ICOFILE}" +convert "${ICOFILES[@]}" "${ICOFILE}" + +# make the .icns +ICNSFILE="${BASENAME}.icns" +echo "Creating ${ICNSFILE}" +png2icns "${ICNSFILE}" "${ICNSFILES[@]}" + +# make the rotatable icon +ROTATABLEFILE="rotatable_${BASENAME}-38.png" +convert "${BASENAME}-38.png" -gravity center -background white -extent 60x60 "${ROTATABLEFILE}" + +exit 0