C:\alpha\gmic\gmic.exe
input 1001,501,1,3,255 
grid 10,10,0,0,1,0,0,0
output C:\alpha\output\gmic_grid_white.png


The command is copy/pastable into the Win 10 PowerShell Command Line... though, I pretty much doubt your copy of G'MIC is located on the same path as mine.

# G'MIC - GRID

• C:\alpha\gmic\gmic.exe 
• Calls G'MIC.
• So if G'MIC is on the System's Path, gmic suffices.
• input 1001,501,1,3,255 
• Creates an all white (255,255,255) RGB image.
• grid 10,10,0,0,1,0,0,0 
• Writes a Black (0,0,0) grid over the lot.
• C:\alpha\output\gmic_grid_white.png
• Saves the image as a PNG.

Shall we do this again?

C:\alpha\gmic\gmic.exe
input 1001,501,1,3 
grid 10,10,0,0,1,255,255,255
output C:\alpha\output\gmic_grid_black.png


First, a breakdown of: input 1001,501,1,3
• input
• If not called out at the beginning of a G'MIC command, it is implicitly called...
• Or so is my understanding.
• But I like to be explicit.
• 1001
• The first number is the width of the new image.
• I'm using an odd size like 1001, as I want a solid border on my image.
• I want the grid lines to start and stop smack dab on the edge of the image.
• 501
• The next number is the height.
• Zero based indexing.
• 0-1000 x 0-500 for this image.
• The first pixel is at 0.
• The last pixel is at (height - 1).
• 501 - 1 = 500
• 1
• The depth.
• I am led to believe G'MIC is a hardcore utility.
• Sure, I use it for fun and games.
• But I am led to believe the creators of G'MIC have higher aspirations than that.
• In short, depth is good for CatScans and Telescopic Night-Sky Surveys.
• 3
• I, on the other hand, will likely only ever use G'MIC for images.
• The final number denotes the Color Channels...
• But this value can be tricked out to incorporate any data type...
• Even if that's not my wheelhouse.

Was that useful?

grid 10,10,0,0,1,255,255,255

What I am using is a shortened version of the full parameter list. Since I have never been able to get the 'pattern' to work (to display anything but a solid line), I see no point in including that optional parameter.

grid 10,10,0,0,1,0xCCCCCCCC,255,255,255

command x_spacing, y_spacing, x_offset, y_offset, opacity, pattern, red, green, blue

I used spaces (for display purposes, so the command does not run off the page), but G'MIC does not accept spaces between parameters. A space means new_command or new_parameter_set. All of the parameters need to be crammed together.

C:\alpha\gmic\gmic.exe 
input 501,501,1,3
fill_color 124,0,255 
grid 50,50,25,25,1,255,0,0
line 0%,0,100%,0,1,255,0,0 
line 0%,1,100%,1,1,255,0,0
line 0%,499,100%,499,1,255,0,0 
line 0%,500,100%,500,1,255,0,0
line 0,0%,0,100%,1,255,0,0 
line 1,0%,1,100%,1,255,0,0
line 499,0%,499,100%,1,255,0,0 
line 500,0%,500,100%,1,255,0,0
output C:\alpha\output\gmic_grid_purple.png

• input 501,501,1,3
• Once again, note the odd sizes.
• Implicit to the call is a trailing zero in the parameter list.
• In the absence of instructions to the contrary, the image will be initialized to zero.
• fill_color 124,0,255
• I don't want a zeroed out (all black image).
• I want a purple (124,0,255) image.
• And typically speaking, I get what I want.

• grid 50,50,25,25,1,255,0,0
• X Spacing
• Y Spacing
• X Offset
• Y Offset
• Opacity
• 0.0 = Can't See
• 1.0 = Full On
• Red
• Green
• Blue
• line 0%,0,100%,0,1,255,0,0
• The parameters for the line command are the exact same as for grid.
• Percentages rather than pixel values can be supplied for either command.
I actually put together this code prior to the much simpler code at the top of the page. For whatever reason, centering the grid and adding a border came into my head prior to resizing the image.

Go figure.