croptool

Image cropping tool
git clone git://lumidify.org/croptool.git (fast, but not encrypted)
git clone https://lumidify.org/croptool.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/croptool.git (over tor)
Log | Files | Refs | README | LICENSE

croptool.1 (5611B)


      1 .Dd August 18, 2023
      2 .Dt CROPTOOL 1
      3 .Os
      4 .Sh NAME
      5 .Nm croptool
      6 .Nd mass image cropping tool
      7 .Sh SYNOPSIS
      8 .Nm
      9 .Op Ar -mr
     10 .Op Ar -f format
     11 .Op Ar -w width
     12 .Op Ar -c padding
     13 .Op Ar -p color
     14 .Op Ar -s color
     15 .Op Ar -z size
     16 .Ar file ...
     17 .Sh DESCRIPTION
     18 .Nm
     19 shows each of the given images and allows a cropping rectangle to be drawn.
     20 On exit, the cropping command is printed for each of the files.
     21 If a file was skipped, nothing is printed for it.
     22 .Sh OPTIONS
     23 .Bl -tag -width Ds
     24 .It Fl m
     25 Disable automatic redrawing when the window is resized (the
     26 .Fl m
     27 stands for 'manual').
     28 This may be useful on older machines that start accelerating global
     29 warming when the image is redrawn constantly while resizing.
     30 Note that this also disables exposure events, so the window has to be
     31 manually redrawn when switching back to it from another window.
     32 .It Fl r
     33 Disable automatic redrawing while the cropping box is being dragged or
     34 resized, for the same reason as
     35 .Fl m .
     36 .It Fl f Ar format
     37 Set the format to be used when the cropping commands are output.
     38 See
     39 .Sx OUTPUT FORMAT
     40 for details.
     41 .It Fl w Ar width
     42 Set the line width of the cropping rectangle in pixels (valid values:
     43 1-99).
     44 Default: 2.
     45 .It Fl c Ar padding
     46 Set the amount of padding used for collision with the mouse in pixels.
     47 This determines how far away the mouse pointer has to be from an edge
     48 or corner of the cropping rectangle to collide with it (valid values:
     49 1-99).
     50 Default: 10.
     51 .It Fl p Ar color
     52 Set the primary color for the cropping rectangle.
     53 Default: #000000.
     54 .It Fl s Ar color
     55 Set the secondary color for the cropping rectangle.
     56 Default: #FFFFFF.
     57 .It Fl z Ar size
     58 Set the Imlib2 in-memory cache to
     59 .Ar size
     60 MiB (valid values: 0-1024).
     61 Default: 4.
     62 .El
     63 .Sh OUTPUT FORMAT
     64 The cropping commands for each image are output using the format given by
     65 .Fl f ,
     66 or the default of
     67 .Ql croptool_crop %wx%h+%l+%t '%f' .
     68 .Pp
     69 The following substitutions are performed:
     70 .Bl -tag -width Ds
     71 .It %%
     72 Print
     73 .Ql % .
     74 .It %w
     75 Print the width of the cropping rectangle in pixels.
     76 .It %h
     77 Print the height of the cropping rectangle in pixels.
     78 .It %l
     79 Print the location of the left side of the cropping rectangle in pixels.
     80 .It %r
     81 Print the location of the right side of the cropping rectangle in pixels.
     82 .It %t
     83 Print the location of the top side of the cropping rectangle in pixels.
     84 .It %b
     85 Print the location of the bottom side of the cropping rectangle in pixels.
     86 .It %f
     87 Print the filename of the image.
     88 Warning: This is printed as is, without any escaping.
     89 .El
     90 .Pp
     91 If an unknown substitution is encountered, a warning is printed to
     92 standard error and the characters are printed verbatim.
     93 .Pp
     94 Note that the coordinates are adjusted so they are entirely within the
     95 image, even if the original cropping rectangle was located partially
     96 outside.
     97 If the cropping rectangle was located entirely outside of the image,
     98 no command is printed for it.
     99 .Sh KEYBINDS
    100 .Bl -tag -width Ds
    101 .It ARROW LEFT
    102 Go to the previous image.
    103 .It ARROW RIGHT
    104 Go to the next image.
    105 .It RETURN
    106 Go to the next image, copying the current cropping rectangle.
    107 Note that this copies the visual rectangle, not the scaled rectangle
    108 that is printed for the cropping command.
    109 In other words, when switching to an image that is a different size and
    110 thus scaled differently, the displayed rectangle will stay the same even
    111 though the pixels covered in the original image are different.
    112 .It SHIFT + RETURN
    113 Go to the previous image, copying the current cropping rectangle.
    114 The same caveat as above applies.
    115 .It TAB
    116 Switch the color of the cropping rectangle between the primary and secondary colors.
    117 .It DELETE
    118 Delete the cropping rectangle of the current image.
    119 .It SPACE
    120 Redraw the window.
    121 This is useful when automatic redrawing is disabled with
    122 .Fl m .
    123 .It q
    124 Exit the program.
    125 .El
    126 .Sh MOUSE ACTIONS
    127 .Bl -tag -width Ds
    128 .It LEFT-CLICK
    129 When inside an existing cropping rectangle, drag it around.
    130 When on one of the edges, resize the rectangle, locking it to that axis.
    131 When on one of the corners, resize the rectangle regardless of axis.
    132 When outside an existing cropping rectangle, replace the current rectangle
    133 with a new one.
    134 .El
    135 .Sh EXIT STATUS
    136 .Ex -std
    137 .Sh EXAMPLES
    138 Normal usage:
    139 .Bd -literal
    140 $ croptool *.jpg > tmp.sh
    141 $ sh tmp.sh
    142 .Ed
    143 .Pp
    144 Or, if you're brave:
    145 .Bd -literal
    146 $ croptool *.jpg | sh
    147 .Ed
    148 .Pp
    149 It is also possible to do more advanced things.
    150 For instance, to save cropped images into a separate directory instead of
    151 overwriting the original images, something like this can be done:
    152 .Bd -literal
    153 $ croptool -f "croptool_crop %wx%h+%l+%t '%f' '/path/to/cropped/%f'" *.jpg | sh
    154 .Ed
    155 .Pp
    156 If more advanced features are needed for the actual cropping (e.g. a
    157 different output format), other tools such as
    158 .Xr convert 1
    159 can be used:
    160 .Bd -literal
    161 $ croptool -f 'convert -crop %wx%h+%l+%t "%f" "$(basename "%f" .jpg).png"' *.jpg | sh
    162 .Ed
    163 .Pp
    164 Note that no great care has been taken to deal with filenames containing
    165 single or double quotes.
    166 That is left as an exercise to the reader (hint: just don't have
    167 filenames containing quotes).
    168 .Sh SEE ALSO
    169 .Xr convert 1 ,
    170 .Xr croptool_crop 1 ,
    171 .Xr mogrify 1
    172 .Sh AUTHORS
    173 .An lumidify Aq Mt nobody@lumidify.org
    174 .Sh BUGS
    175 The filenames are printed without any escaping, so filenames with
    176 quotes may cause issues depending on the output format.
    177 .Pp
    178 Transparent portions of images should probably be shown differently,
    179 but I'm too lazy to fix that and don't really care at the moment.
    180 .Pp
    181 Since the coordinates of the cropping rectangle are stored as integers,
    182 they will become skewed while resizing.
    183 If this becomes a real problem, though, you're probably doing something
    184 wrong anyways.