There is no particular difficulty in creating a grid using a separate program and importing it into a GIMP file as a layer. Then you can make it visible or invisible, change it’s position in the stack of layers, modify it, etc., just like any other layer.
The following ad hoc MetaPost program will create a 20cm x 10cm grid. Of course, many other graphics programs could be used instead.
%% ttemp.mp
prologues := 3;
outputtemplate := “%j%1c.ps”;
pen medium_pen;
medium_pen = pencircle scaled .5mm;
path p<left square bracket, right square bracket>; % Brackets aren’t
% displaced correctly by the forum software
p0 = (0, -5cm) – (0, 5cm);
p1 = (-10cm, 0) – (10cm, 0);
beginfig(0);
pickup medium_pen;
fill (-10cm, -5cm) – (10cm, -5cm) – (10cm, 5cm) – (-10cm, 5cm) – cycle withcolor white;
for i = -10 upto 10:
draw p0 shifted (i*cm, 0);
endfor;
for i = -5 upto 5:
draw p1 shifted (0, i*cm);
endfor;
endfig;
end;
To run this program, call this command from the command line:
mpost -numbersystem=“double” ttemp.mp
There are a couple of complications: MetaPost can also generate PNG and SVG files, but PNG the only format where you can specify a color format with an alpha channel or turn off antialiasing. I often use these features but in this example I got poor results because the lines were not all of the right thickness. Presumably, this happened during scan conversion and it might be possible to fix it by shifting the entire image slightly in one direction or another.
However, I decided just to create PostScript output instead. In this case, the option “Graphic antialiasing” must be set to “none” when importing the file into GIMP. The command “prologues := 3;” in the MetaPost file causes MetaPost to produce “standalone” rather than encapsulated PostScript. For GIMP, there is no significant difference (and maybe no difference at all), but generating standalone PostScript makes it possible to view the image in PostScript viewers that can’t handle EPS that isn’t embedded in a standalone PS file.
The option -numbersystem=“double” in the call to mpost is probably not needed for this example, but if it’s not used, MetaPost uses the default low precision for arithmetical operations, which was a concession to the limitations of computers in the mid 1980s.
Unfortunately, PostScript doesn’t support transparency, but there is no difficulty in changing the white background to be transparent in GIMP.
The grid can be aligned in various ways with the original image. Values can be set in the MetaPost or the layer can be shifted or otherwise transformed in GIMP and there may be other ways of doing this.
Of course, units other than cm can be used and the values don’t have to be integers.