From 80631121bc2a0fdce1a684f5f2fbf12ff3de9998 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 1 Apr 2024 17:41:55 +0100 Subject: [PATCH] Generate a blank copy of the grid in a separate image --- README.md | 5 ++++- griddle | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 31a5fdb..53bd907 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,14 @@ This is the number of **columns** and **rows**, not the number of separators. For example, specifying "2" columns will result in **one** line splitting the image vertically. Border lines around the edge of the image are always generated. +`griddle` also generates an image named "blank_grid.png", which is an exact copy of the grid generated on top of the input image, but with a blank white background. +This can then be printed out and used to draw on, instead of manually trying to recreate the grid on paper, if you both have a printer and are using a kind of paper that can be used in said printer. +(I don't have a printer, but I figured someone might find this feature useful.) + It supports any input and output file formats that ImageMagick supports. The input and output files don't need to be the same format; you can input a PNG and output a JPEG, for example. ## Planned Features -- Generate an additional output image (or PDF?) containing a blank copy of just the generated grid which can be printed out, to save the effort of manually recreating the grid on your drawing paper. - Improve the CLI interface with `--options` to remove the arbitrary ordering of `` and ``. - Make border lines optional. - Allow the user to adjust the color and transparency of grid lines. diff --git a/griddle b/griddle index 7b64ac3..bccb0e8 100755 --- a/griddle +++ b/griddle @@ -43,7 +43,7 @@ generate_lines() { done } -create_image() { +draw_image_with_grid() { inputfile="$1" lines="$2" outputfile="$3" @@ -51,6 +51,14 @@ create_image() { convert -draw "$lines" "$inputfile" "$outputfile" } +draw_blank_grid() { + lines="$1" + width="$2" + height="$3" + + convert -size "${width}x${height}" canvas:white -draw "$lines" blank_grid.png +} + main() { if test "$#" -ne 4; then printf "Usage: griddle \n" @@ -83,7 +91,8 @@ main() { lines="$(generate_lines $columns $rows $width $height)" - create_image "$inputfile" "$lines" "$outputfile" + draw_image_with_grid "$inputfile" "$lines" "$outputfile" + draw_blank_grid "$lines" "$width" "$height" } main "$@"