CROPTOOL(1) General Commands Manual CROPTOOL(1)

croptoolmass image cropping tool

croptool [-mr] [-f format] [-w width] [-c padding] [-p color] [-s color] file ...

croptool shows each of the given images and allows a cropping rectangle to be drawn. On exit, the cropping command is printed for each of the files. If a file was skipped, nothing is printed for it.

Disable automatic redrawing when the window is resized (the -m stands for 'manual'). This may be useful on older machines that start accelerating global warming when the image is redrawn constantly while resizing. Note that this also disables exposure events, so the window has to be manually redrawn when switching back to it from another window.
Disable automatic redrawing while the cropping box is being dragged or resized, for the same reason as -m.
Set the format to be used when the cropping commands are output. See OUTPUT FORMAT for details.
Set the line width of the cropping rectangle in pixels (valid values: 1-99). Default: 2.
Set the amount of padding used for collision with the mouse in pixels. This determines how far away the mouse pointer has to be from an edge or corner of the cropping rectangle to collide with it (valid values: 1-99). Default: 10.
Set the primary color for the cropping rectangle. Default: #000000.
Set the secondary color for the cropping rectangle. Default: #FFFFFF.

The cropping commands for each image are output using the format given by -f, or the default of ‘croptool_crop %wx%h+%l+%t '%f'’. The following substitutions are performed:

Print ‘%’.
Print the width of the cropping rectangle in pixels.
Print the height of the cropping rectangle in pixels.
Print the location of the left side of the cropping rectangle in pixels.
Print the location of the right side of the cropping rectangle in pixels.
Print the location of the top side of the cropping rectangle in pixels.
Print the location of the bottom side of the cropping rectangle in pixels.
Print the filename of the image. Warning: This is printed as is, without any escaping.

If an unknown substitution is encountered, a warning is printed to standard error and the characters are printed verbatim.

Go to the last image.
Go to the next image.
Go to the next image, copying the current cropping rectangle. Note that this copies the visual rectangle, not the scaled rectangle that is printed for the cropping command. In other words, when switching to an image that is a different size and thus scaled differently, the displayed rectangle will stay the same even though the pixels covered in the original image are different.
Switch the color of the cropping rectangle between the primary and secondary colors.
Delete the cropping rectangle of the current image.
Redraw the window. This is useful when automatic redrawing is disabled with -m.

When inside an existing cropping rectangle, drag it around. When on one of the edges, resize the rectangle, locking it to that axis. When on one of the corners, resize the rectangle regardless of axis. When outside an existing cropping rectangle, replace the current rectangle with a new one.

The croptool utility exits 0 on success, and >0 if an error occurs.

Normal usage:

$ croptool *.jpg >
$ sh

Or, if you're brave:

$ croptool *.jpg | sh

It is also possible to do more advanced things. For instance, to save cropped images into a separate directory instead of overwriting the original images, something like this can be done:

$ croptool -f "croptool_crop %wx%h+%l+%t '%f' '/path/to/cropped/%f'" *.jpg | sh

If more advanced features are needed for the actual cropping (e.g. a different output format), other tools such as convert(1) can be used:

$ croptool -f 'convert -crop %wx%h+%l+%t "%f" "$(basename "%f" .jpg).png"' *.jpg | sh

Note that no great care has been taken to deal with filenames containing single or double quotes. That is left as an exercise to the reader (hint: just don't have filenames containing quotes).

convert(1), croptool_crop(1), mogrify(1)

lumidify <>

The filenames are printed without any escaping, so filenames with quotes may cause issues depending on the output format.

Transparent portions of images should probably be shown differently, but I'm too lazy to fix that and don't really care at the moment.

Since the coordinates of the cropping rectangle are stored as integers, they will become skewed while resizing. If this becomes a real problem, though, you're probably doing something wrong anyways.

April 1, 2021