Michael Barton wrote:
Perhaps I'm missing something, but as I understood the proposed changes to
the script itself, the file names are generated in the bash script.
The script generates the filenames for the intermediate files (the
ones produced by the individual d.* commands within the script). The
final step is to use g.pnmcomp to overlay the intermediate files, with
the output to $GRASS_PNGFILE.
The end result is that the script behaves like any other d.* command.
You set GRASS_PNGFILE (etc) and run it; when it's finished, you have
the images where you asked for them.
I really don't see how I can explain it any more clearly than that. I
don't even see what was unclear about the original suggestion:
From: Glynn Clements <glynn@gclements.plus.com>
Subject: Re: [GRASS-dev] Re: windows binaries
Date: Thu, 9 Nov 2006 22:19:32 +0000
Message-ID: <17747.43380.785380.210356@cerise.gclements.plus.com>
AFAICT, the necessary changes would be:
1. At the start of the script:
if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
imgbase=${GRASS_PNGFILE%.ppm}
fi
This makes a note of the base filename ($GRASS_PNGFILE, with the .ppm
suffix removed). This will be used for intermediate files, so that
they use the same directory, retain the PID, etc. Also, this makes it
easier to refer to both the .ppm and .pgm files.
2. After each d.* command:
if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
mv $imgbase.ppm $imgbase.$num.ppm # each image needs a different number
if [ $GRASS_TRANSPARENT = TRUE ] ; then
mv $imgbase.pgm $imgbase.$num.pgm
fi
fi
d.* commands write their output to $GRASS_PNGFILE (and the
corresponding .pgm file if transparency is enabled). The above moves
them out of the way so that they don't get clobbered by subsequent d.*
commands.
Note: $imgbase.ppm is equal to $GRASS_PNGFILE, as $imgbase is just
$GRASS_PNGFILE with the .ppm suffix removed (step 1 above).
3. At the end of the script:
if [ $GRASS_RENDER_IMMEDIATE = TRUE ] ; then
if [ $GRASS_TRANSPARENT = TRUE ] ; then
g.pnmcomp \
output=$imgbase.ppm \
width=$GRASS_WIDTH \
height=$GRASS_HEIGHT \
input=$imgbase.1.ppm,$imgbase.2.ppm \
mask=$imgbase.1.pgm,$imgbase.2.pgm
else
g.pnmcomp \
output=$imgbase.ppm \
width=$GRASS_WIDTH \
height=$GRASS_HEIGHT \
input=$imgbase.1.ppm,$imgbase.2.ppm
fi
fi
This overlays the intermediate files, with the result going to
$GRASS_PNGFILE.
It needs a slight modification: the transparent case needs:
outmask=$imgbase.pgm \
added.
Also, the intermediate files should be deleted at this point.
--
Glynn Clements <glynn@gclements.plus.com>