[GRASS-SVN] r70137 - in grass/trunk: gui/images/symbols tools
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Dec 26 20:58:18 PST 2016
Author: wenzeslaus
Date: 2016-12-26 20:58:18 -0800 (Mon, 26 Dec 2016)
New Revision: 70137
Added:
grass/trunk/tools/symbol_to_img.sh
Modified:
grass/trunk/gui/images/symbols/README
Log:
move symbol PNG generation to a script
Modified: grass/trunk/gui/images/symbols/README
===================================================================
--- grass/trunk/gui/images/symbols/README 2016-12-27 04:49:00 UTC (rev 70136)
+++ grass/trunk/gui/images/symbols/README 2016-12-27 04:58:18 UTC (rev 70137)
@@ -1,39 +1,19 @@
Symbols in form of PNG images enable to choose easily symbols in d.vect
-and in wx.psmap dialogs. It is necessary to keep images synchronized with
-symbols from ./lib/symbol/symbol/ directories.
+and in g.gui.psmap dialogs. It is necessary to keep images synchronized
+with symbols from ./lib/symbol/symbol/ directories.
-How to create new symbol image:
-----------------------------------
-You can use following script (requires Inkscape), run script in symbol group
-directory (e.g. ./lib/symbol/symbol/basic) within a GRASS session.
-Optipng will try to make the file as small as possible.
+How to create new symbol image
+------------------------------
-#!/bin/sh
-DIR="$(basename $PWD)"
-PSMAP_FILE=tmp.psmap
-PS_FILE=tmp.ps
-PNG_OUT=png_out
+You can use following script (see its code for runtime requirements),
+run script in symbol group directory (e.g. ./lib/symbol/symbol/basic)
+within a GRASS session. ImageMagic should take care of compressing the
+image as much as possible.
-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"
+ tools/symbol_to_img.sh
- #optipng -o5 "$PNG_OUT/$SYMBOL.png"
- else
- echo "$SYMBOL is not regular file"
- fi
-done
-
Image should have 30x30 px to be displayed correctly in GUI dialog. If the symbol
has different width and height, you are supposed to correct it (for example
in Gimp see Image -> Canvas size). Also consider where the reference point of symbol
-is placed (see e.g. offbox_ne, offbox_ns symbols).
-
+is placed (see e.g. offbox_ne, offbox_ns symbols). If you don't do that
+it will be badly displayed in the GUI.
Copied: grass/trunk/tools/symbol_to_img.sh (from rev 70128, grass/trunk/gui/images/symbols/README)
===================================================================
--- grass/trunk/tools/symbol_to_img.sh (rev 0)
+++ grass/trunk/tools/symbol_to_img.sh 2016-12-27 04:58:18 UTC (rev 70137)
@@ -0,0 +1,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
More information about the grass-commit
mailing list