Debian Codegraph @

scripts/svg_to_png.sh

raw symbols SCIP
1 #!/bin/bash
2
3 # abort on first error
4 set -e
5
6 if [[ ! $@ ]]; then
7 echo 'Updates the the PNG icons of the projects in the specified directories.'
8 echo 'However, no project directories have been specified.'
9 exit -1
10 fi
11
12 # define array for commands to be executed
13 cmds=()
14
15 # iterate over specified source directories
16 for srcdir in "$@"; do
17 # find SVG icons
18 for svg_icon_full_path in $(find "$srcdir" -iname '*.svg'); do
19 prefix="${svg_icon_full_path%/scalable/*}"
20 svg_icon="${svg_icon_full_path##*/scalable/}"
21 # add inkscape command for each icon and size and ensure output directory exists
22 for size in 16 32 48; do
23 mkdir -p "${prefix}/${size}x${size}/${svg_icon%/*.svg}"
24 cmds+=("inkscape --without-gui \"${svg_icon_full_path}\" --export-png=\"${prefix}/${size}x${size}/${svg_icon%.svg}.png\" --export-width=${size} --export-height=${size}")
25 done
26 done
27 done
28
29 # run commands
30 function print_cmds {
31 for cmd in "${cmds[@]}"; do
32 echo "$cmd"
33 done
34 }
35 echo "Executing the following commands:"
36 print_cmds
37 print_cmds | parallel