[GRASSLIST:780] Re: p.map.new & rast2gif (in GRASSLinks)

H Bowman hamish_nospam at yahoo.com
Mon Jul 21 21:27:25 EDT 2003


> 2. if ppmtogif works. ppmtogif is a tool of unix/lunix. It read
> the paiint.ppm and convert it into gif. So, please make sure
> setup for directory is correct.

More precisely it is an ImageMagick tool, and runs on all Unix/Windows/Mac.
http://www.imagemagick.org


You might also want to try the GRASS PNG Driver or X window dump.
Another approach is ps.map to pstopnm|pnmtopng if you prefer.

Here are some Bash scripts for making PNG hardcopies of a GRASS monitor--
===
d.out.png.xwd:
#!/bin/sh
# WYSIWYG but not double buffered
if [ -z $GISBASE ] ; then
        echo "You have to be in GRASS to use this."
        exit
fi
if [ -z "$1" ] ; then
        echo "USAGE: d.out.png PNGfilename  (.png added automatically)"
        echo "       Make a PNG hardcopy of a GRASS monitor"
        exit
else
        OLD_MON=`d.mon -p | awk '{printf "%s", $4}'`
        GRASS_VER=`g.version | awk '{printf "%s", $1 " " $2}'`
        export GRASS_PNGFILE="$1".png
        echo "Exporting to $GRASS_PNGFILE from [$GRASS_VER- Monitor: $OLD_MON]"
        xwd -name "$GRASS_VER- Monitor: $OLD_MON" | xwdtopnm | pnmtopng > $GRASS_PNGFILE
fi

===

d.out.png.driver:
#!/bin/sh
# double buffered but not WYSIWYG
if [ -z $GISBASE ] ; then
        echo "You have to be in GRASS to use this."
        exit
fi
if [ -z "$1" ] ; then
        echo "USAGE: d.out.png PNGfilename  (.png added automatically)"
        echo "       Make a PNG hardcopy of a GRASS monitor"
        exit
else
        OLD_MON=`d.mon -p | awk '{printf "%s", $4}'`
        GRASS_VER=`g.version | awk '{printf "%s", $1 " " $2}'`
        export GRASS_PNGFILE="$1".png
        echo "Exporting to $GRASS_PNGFILE from [$GRASS_VER- Monitor: $OLD_MON]"
        xwininfo -name "$GRASS_VER- Monitor: $OLD_MON" > /tmp/GRASS.wininfo.$$
        export GRASS_WIDTH=`grep Width /tmp/GRASS.wininfo.$$ | awk '{printf "%d", $2}'`
        export GRASS_HEIGHT=`grep Height /tmp/GRASS.wininfo.$$ | awk '{printf "%d", $2}'`
        rm -f /tmp/GRASS.wininfo.$$
#       export GRASS_TRUECOLOR=TRUE   # with GD-2.0
        d.save -c > /tmp/GRASS_pngmap.$$
        d.mon start=PNG
        d.mon select=PNG
        . /tmp/GRASS_pngmap.$$
        d.mon stop=PNG
        echo "Processed monitor "$OLD_MON" ["$GRASS_WIDTH"x$GRASS_HEIGHT] to $GRASS_PNGFILE"
        rm -f /tmp/GRASS_pngmap.$$
        d.mon select=$OLD_MON
        sleep 1         # wait for file to finish writing
#       eeyes "$1".png &
fi

===
Hamish




More information about the grass-user mailing list