Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / resources / stock_icons / svg-to-png.sh
blobc8f6613037032c691add9e95d67acf078af39c9f
1 #!/bin/bash
2 # svg-to-png
3 # Convert SVG files to 1x and 2x PNGs. Dump a list of Qt resource
4 # file entries upon successful completion.
6 # Copyright 2014 Gerald Combs <gerald [AT] wireshark.org>
8 # Wireshark - Network traffic analyzer
9 # By Gerald Combs <gerald@wireshark.org>
10 # Copyright 1998 Gerald Combs
12 # SPDX-License-Identifier: GPL-2.0-or-later
14 COMMON_ARGS="--export-area-page"
16 #SVGCLEANER=$( type -p svgcleaner )
18 set_source_svgs() {
19 local out_icon=$1
20 case $out_icon in
21 x-capture-options)
22 out_icon=x-capture-options-gear
24 x-capture-restart)
25 out_icon=x-capture-restart-fin
27 x-capture-stop)
28 out_icon=x-capture-stop-red
30 esac
31 ONE_X_SVG=${out_icon}.svg
32 TWO_X_SVG=${out_icon}@2x.svg
33 if [ ! -f "${TWO_X_SVG}" ] ; then
34 TWO_X_SVG=$ONE_X_SVG
38 ICONS="
39 edit-find.template
40 go-first
41 go-jump
42 go-last
43 go-next
44 go-previous
45 x-capture-file-close
46 x-capture-file-save
47 x-capture-file-reload
48 x-capture-filter-bookmark
49 x-capture-filter-bookmark.active
50 x-capture-filter-bookmark.selected
51 x-capture-options
52 x-capture-restart
53 x-capture-start.on
54 x-capture-start
55 x-capture-stop
56 x-colorize-packets
57 x-display-filter-bookmark
58 x-display-filter-bookmark.active
59 x-display-filter-bookmark.selected
60 x-filter-apply
61 x-filter-apply.active
62 x-filter-apply.selected
63 x-filter-clear
64 x-filter-clear.active
65 x-filter-clear.selected
66 x-filter-deprecated
67 x-filter-dropdown.dark
68 x-filter-dropdown.light
69 x-filter-invalid
70 x-filter-matching-bookmark
71 x-filter-matching-bookmark.active
72 x-filter-matching-bookmark.selected
73 x-hide-ro
74 x-resize-columns
75 x-stay-last
76 zoom-in.template
77 zoom-original.template
78 zoom-out.template
81 if [ -n "$*" ] ; then
82 ICONS="$*"
85 QRC_FILES=""
87 # 12x12
88 for SIZE in 14x14 16x16 24x14 24x24 ; do
89 WIDTH=${SIZE/x*/}
90 HEIGHT=${SIZE/*x/}
91 SIZE_DIR=${SIZE}
93 TWO_X_WIDTH=$(( WIDTH * 2 ))
94 TWO_X_HEIGHT=$(( HEIGHT * 2 ))
95 ONE_X_ARGS="--export-width=${WIDTH} --export-height=${HEIGHT}"
96 TWO_X_ARGS="--export-width=${TWO_X_WIDTH} --export-height=${TWO_X_HEIGHT}"
98 echo "Converting $SIZE_DIR"
99 cd $SIZE_DIR || exit 1
101 for ICON in $ICONS ; do
102 echo "Converting $ICON"
104 # XXX This seems to modify the SVG too much. Need to
105 # investigate.
106 #if [ -n "$SVGCLEANER" ] ; then
107 # mv "$ICON.svg" "$ICON.dirty.svg"
108 # $SVGCLEANER "$ICON.dirty.svg" "$ICON.svg"
109 # rm "$ICON.dirty.svg"
112 set_source_svgs "$ICON"
114 if [ ! -f "${ONE_X_SVG}" ] ; then
115 >&2 echo "Skipping ${ONE_X_SVG}"
116 continue
119 ONE_X_PNG=${ICON}.png
120 TWO_X_PNG=${ICON}@2x.png
122 if [ "$ONE_X_SVG" -nt "$ONE_X_PNG" ] ; then
123 # shellcheck disable=SC2086
124 inkscape $COMMON_ARGS $ONE_X_ARGS \
125 --file="$PWD/$ONE_X_SVG" --export-png="$PWD/$ONE_X_PNG" || exit 1
126 QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${ONE_X_PNG}"
129 if [ "$TWO_X_SVG" -nt "$TWO_X_PNG" ] ; then
130 # shellcheck disable=SC2086
131 inkscape $COMMON_ARGS $TWO_X_ARGS \
132 --file="$PWD/$TWO_X_SVG" --export-png="$PWD/$TWO_X_PNG" || exit 1
133 QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${TWO_X_PNG}"
136 done
138 cd ..
140 done
142 for QRC_FILE in $QRC_FILES ; do
143 echo " <file>stock_icons/${QRC_FILE}</file>"
144 done
147 # Editor modelines - https://www.wireshark.org/tools/modelines.html
149 # Local variables:
150 # c-basic-offset: 4
151 # tab-width: 8
152 # indent-tabs-mode: nil
153 # End:
155 # vi: set shiftwidth=4 tabstop=8 expandtab:
156 # :indentSize=4:tabSize=8:noTabs=true: