Generate a blank copy of the grid in a separate image

This commit is contained in:
The Magician 2024-04-01 17:41:55 +01:00
parent cf15edd064
commit 80631121bc
2 changed files with 15 additions and 3 deletions

View File

@ -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. 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. 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. 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. 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 ## 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 `<number_of_columns>` and `<number_of_rows>`. - Improve the CLI interface with `--options` to remove the arbitrary ordering of `<number_of_columns>` and `<number_of_rows>`.
- Make border lines optional. - Make border lines optional.
- Allow the user to adjust the color and transparency of grid lines. - Allow the user to adjust the color and transparency of grid lines.

13
griddle
View File

@ -43,7 +43,7 @@ generate_lines() {
done done
} }
create_image() { draw_image_with_grid() {
inputfile="$1" inputfile="$1"
lines="$2" lines="$2"
outputfile="$3" outputfile="$3"
@ -51,6 +51,14 @@ create_image() {
convert -draw "$lines" "$inputfile" "$outputfile" 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() { main() {
if test "$#" -ne 4; then if test "$#" -ne 4; then
printf "Usage: griddle <inputfile> <columns> <rows> <outputfile>\n" printf "Usage: griddle <inputfile> <columns> <rows> <outputfile>\n"
@ -83,7 +91,8 @@ main() {
lines="$(generate_lines $columns $rows $width $height)" 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 "$@" main "$@"