JAL-4012 tweak release notes wording for legacy.uniprot
[jalview.git] / utils / mk_jalview_icons.sh
1 #!/usr/bin/env bash
2
3 FILENAME512=$1
4 BASENAME=${FILENAME512%-512.png}
5
6 usage () {
7   echo "$(basename "$0") <LOGO_NAME>-512.png"
8 }
9
10 [ "$1" = "-h" ] && usage && exit 0
11 [ -r "$FILENAME512" ] || ( usage && echo "'${FILENAME512}' must exist and be readable" && exit 1 )
12 [ "$BASENAME" = "$FILENAME512" ] && usage && echo "Must have '-512.png' at end of filename" && exit 2
13
14 set -e
15
16 SIZES="16 32 38 48 64 128 256"
17 declare -a ICOFILES=()
18 declare -a ICNSFILES=()
19 for n in $SIZES
20 do
21   NEWFILE="${BASENAME}-${n}.png"
22   [ -e "{$NEWFILE}" ] && continue
23   convert -geometry "${n}x${n}" "${BASENAME}-512.png" "${NEWFILE}"
24   [ "${n}" != 38 ] && ICOFILES=( "${ICOFILES[@]}" "${NEWFILE}" )
25   [ "${n}" != 64 ] && [ "${n}" != 38 ] && ICNSFILES=( "${ICNSFILES[@]}" "${NEWFILE}" )
26 done
27
28 # make the .ico
29 ICOFILE="${BASENAME}.ico"
30 echo "Creating ${ICOFILE}"
31 convert "${ICOFILES[@]}" "${ICOFILE}"
32
33 # make the .icns
34 ICNSFILE="${BASENAME}.icns"
35 echo "Creating ${ICNSFILE}"
36 png2icns "${ICNSFILE}" "${ICNSFILES[@]}"
37
38 # make the rotatable icon
39 ROTATABLEFILE="rotatable_${BASENAME}-38.png"
40 convert "${BASENAME}-38.png" -gravity center -background white -extent 60x60 "${ROTATABLEFILE}"
41
42 exit 0