forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbol_to_img.sh
executable file
·52 lines (43 loc) · 1.48 KB
/
symbol_to_img.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
############################################################################
#
# MODULE: symbol_to_img.sh
# AUTHOR(S): Anna Petrasova, Hamish Bowman, Vaclav Petras
# PURPOSE: Renders the GRASS GIS symbols from dir to a dir of PNGs
# COPYRIGHT: (C) 2012-2016 by Anna Petrasova
# and the GRASS Development Team
#
# This program is free software under the GNU General
# Public License (>=v2). Read the file COPYING that
# comes with GRASS for details.
#
#############################################################################
# generates images for gui/images/symbols
# requires ps.map, Inkscape, and ImageMagic
DIR="$(basename $PWD)"
PSMAP_FILE=tmp.psmap
PS_FILE=tmp.ps
PNG_OUT=png_out
POINT_VECTOR=tmp_one_point
v.in.ascii input=- format=standard -n output=$POINT_VECTOR <<EOF
P 1 1
100 100
1 1
EOF
rm -r "$PNG_OUT"
mkdir "$PNG_OUT"
for SYMBOL in *
do
if [ -f "$SYMBOL" ]
then
echo -e "border none\npoint 50% 50%\n symbol $DIR/$SYMBOL\n end\nend" > "$PSMAP_FILE"
ps.map input="$PSMAP_FILE" output="$PS_FILE"
inkscape -f "$PS_FILE" --export-png="$PNG_OUT/$SYMBOL.png" -D -h=30
rm "$PSMAP_FILE" "$PS_FILE"
# ImageMagic optimizes PNGs, no optipng needed
mogrify -gravity center -background transparent -resize 30x30 -extent 30x30 "$PNG_OUT/$SYMBOL.png"
else
echo "$SYMBOL is not regular file"
fi
done
g.remove type=vector name=$POINT_VECTOR -f