Here are a couple of bash scripts that can be used to overlay grid lines or insert grid lines. The first will keep the image the same size, the second will enlarge the image. The second approach was based upon a suggestion by glennrp. Horizontal and vertical spacing and color can be specified separately, but grid thickness will be the same but adjustable.
Input
Method 1: Overlay Grid Lines
infile="lena.jpg"
hcolor="white"
vcolor="black"
thickness=3
xspace=24
yspace=24
ww=`convert $infile -format "%w" info:`
hh=`convert $infile -format "%h" info:`
inname=`convert $infile -format "%t" info:`
convert $infile \
\( -size ${xspace}x${yspace} xc:none -background none -fill none -strokewidth $thickness \
-draw "stroke $vcolor line 0,0 0,$((yspace-1)) stroke $hcolor line 0,0 $((xspace-1)),0" -write mpr:grid +delete \
-size ${ww}x${hh} tile:mpr:grid \) -compose over -composite ${inname}_grid.jpg
Method 2: Insert Grid Lines
infile="lena.jpg"
hcolor="white"
vcolor="black"
thickness=3
xspace=24
yspace=24
ww=`convert $infile -format "%w" info:`
hh=`convert $infile -format "%h" info:`
nx=`convert xc: -format "%[fx:round($ww/$xspace)]" info:`
ny=`convert xc: -format "%[fx:round($hh/$yspace)]" info:`
inname=`convert $infile -format "%t" info:`
convert $infile -crop ${xspace}x${yspace} +repage \
-background $vcolor -gravity west -splice ${thickness}x0 \
-background $hcolor -gravity north -splice 0x${thickness} \
miff:- | montage - -geometry +0+0 -tile ${nx}x${ny} ${inname}_grid_expand.jpg
These two scripts should not be too hard to convert to windows. See
http://www.imagemagick.org/Usage/windows/