| CROPTOOL(1) | General Commands Manual | CROPTOOL(1) |
croptool — mass
image cropping tool
croptool |
[-mr] [-f format] [-w width] [-c padding] [-p color] [-s color] [-z size] file ... |
croptool shows each of the given images
and allows a cropping rectangle to be drawn. When the keyboard command
‘q’ is used to exit, the cropping command is printed for each
of the images. If an image was skipped, nothing is printed for it.
-m-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.-r-m.-f
format-w
width-c
padding-p
color-s
color-z
sizeThe 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:
%’.If an unknown substitution is encountered, a warning is printed to standard error and the characters are printed verbatim.
Note that the coordinates are adjusted so they are entirely within the image, even if the original cropping rectangle was located partially outside. If the cropping rectangle was located entirely outside of the image, no command is printed for it.
-m.The croptool utility exits 0 on
success, and >0 if an error occurs.
Normal usage:
$ croptool *.jpg > tmp.sh $ sh tmp.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
With convert(1) or mogrify(1), it is also possible to specify the compression level for JPEG images:
$ croptool -f 'mogrify -quality 90 -crop %wx%h+%l+%t "%f"' *.jpg | sh
Using convert(1) or mogrify(1) has the additional benefit of preserving the EXIF tags embedded in an image, which is a feature croptool_crop(1) currently lacks.
For ImageMagick 7, ‘convert’
and ‘mogrify’ need to be replaced with
‘magick’ and
‘magick mogrify’, respectively.
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), ImageMagick(1), mogrify(1), selectool(1)
lumidify <nobody@lumidify.org>
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.
| July 12, 2026 |