regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / resources / stock_icons / layouts-to-png.sh
blob4572652cd3c7346f2a8c1f8cf2d96b9ea6a0e46c
1 #!/bin/bash
2 # layouts-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 # Running on WSL. Set as needed for Mac/linux.
19 INKSCAPE_EXE="inkscape.com"
21 ICONS="
22 layout_1
23 layout_2
24 layout_3
25 layout_4
26 layout_5
27 layout_6
30 if [ -n "$*" ] ; then
31 ICONS="$*"
34 QRC_FILES=""
36 for SIZE in 16x16 24x24 ; do
37 WIDTH=${SIZE/x*/}
38 HEIGHT=${SIZE/*x/}
39 SIZE_DIR=${SIZE}
41 TWO_X_WIDTH=$(( WIDTH * 2 ))
42 TWO_X_HEIGHT=$(( HEIGHT * 2 ))
43 ONE_X_ARGS="--export-width=${WIDTH} --export-height=${HEIGHT}"
44 TWO_X_ARGS="--export-width=${TWO_X_WIDTH} --export-height=${TWO_X_HEIGHT}"
46 echo "Converting $SIZE_DIR"
47 cd $SIZE_DIR || exit 1
49 for ICON in $ICONS ; do
50 echo "Converting $ICON"
52 ONE_X_SVG="../../layouts.svg"
53 TWO_X_SVG=$ONE_X_SVG
55 ICONNAME="x-reset-$ICON"
56 ONE_X_PNG=${ICONNAME}.png
57 TWO_X_PNG=${ICONNAME}@2x.png
59 if [ "$ONE_X_SVG" -nt "$ONE_X_PNG" ] ; then
60 # shellcheck disable=SC2086
61 $INKSCAPE_EXE $COMMON_ARGS $ONE_X_ARGS --export-id="$ICON" \
62 --export-filename="$ONE_X_PNG" $ONE_X_SVG || exit 1
63 QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${ONE_X_PNG}"
66 if [ "$TWO_X_SVG" -nt "$TWO_X_PNG" ] ; then
67 # shellcheck disable=SC2086
68 $INKSCAPE_EXE $COMMON_ARGS $TWO_X_ARGS --export-id="$ICON" \
69 --export-filename="$TWO_X_PNG" $TWO_X_SVG || exit 1
70 QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${TWO_X_PNG}"
73 done
75 cd ..
77 done
79 for QRC_FILE in $QRC_FILES ; do
80 echo " <file>stock_icons/${QRC_FILE}</file>"
81 done
83 echo "--------------------------------------"
84 QRC_FILES=""
86 for SIZE in 48x48 96x96 ; do
87 WIDTH=${SIZE/x*/}
88 HEIGHT=${SIZE/*x/}
89 OUT_DIR=".."
91 TWO_X_WIDTH=$(( WIDTH * 2 ))
92 TWO_X_HEIGHT=$(( HEIGHT * 2 ))
93 ONE_X_ARGS="--export-width=${WIDTH} --export-height=${HEIGHT}"
94 TWO_X_ARGS="--export-width=${TWO_X_WIDTH} --export-height=${TWO_X_HEIGHT}"
96 echo "Converting $OUT_DIR"
98 for ICON in $ICONS ; do
99 echo "Converting $ICON"
101 ONE_X_SVG=${OUT_DIR}/layouts.svg
102 TWO_X_SVG=$ONE_X_SVG
104 ICONNAME="$ICON"
105 ONE_X_PNG=${OUT_DIR}/${ICONNAME}.png
106 TWO_X_PNG=${OUT_DIR}/${ICONNAME}@2x.png
108 if [ "$ONE_X_SVG" -nt "$ONE_X_PNG" ] ; then
109 # shellcheck disable=SC2086
110 $INKSCAPE_EXE $COMMON_ARGS $ONE_X_ARGS --export-id="$ICON" \
111 --export-filename="$ONE_X_PNG" $ONE_X_SVG || exit 1
112 QRC_FILES="${QRC_FILES} ${ICONNAME}.png"
115 if [ "$TWO_X_SVG" -nt "$TWO_X_PNG" ] ; then
116 # shellcheck disable=SC2086
117 $INKSCAPE_EXE $COMMON_ARGS $TWO_X_ARGS --export-id="$ICON" \
118 --export-filename="$TWO_X_PNG" $TWO_X_SVG || exit 1
119 QRC_FILES="${QRC_FILES} ${ICONNAME}@2x.png"
122 done
124 done
126 for QRC_FILE in $QRC_FILES ; do
127 echo " <file>${QRC_FILE}</file>"
128 done
130 # Editor modelines - https://www.wireshark.org/tools/modelines.html
132 # Local variables:
133 # c-basic-offset: 4
134 # tab-width: 8
135 # indent-tabs-mode: nil
136 # End:
138 # vi: set shiftwidth=4 tabstop=8 expandtab:
139 # :indentSize=4:tabSize=8:noTabs=true: