|CROPTOOL(1)||General Commands Manual||CROPTOOL(1)|
croptool — mass
image cropping tool
||[-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
-mstands 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.
The cropping commands for each image are output using the format
-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.
croptool utility exits 0 on
success, and >0 if an error occurs.
$ 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
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).
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|