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. On exit, the cropping command
is printed for each of the files. If a file 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
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).
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.
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.
May 14, 2024 |