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 (5777B)


      1 .Dd May 14, 2024
      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
    117 secondary colors.
    118 .It DELETE
    119 Remove the cropping rectangle of the current image.
    120 .It SPACE
    121 Redraw the window.
    122 This is useful when automatic redrawing is disabled with
    123 .Fl m .
    124 .It q
    125 Exit the program, printing the cropping command for any images with a
    126 cropping rectangle set.
    127 If the window is closed through some other means, no commands are printed.
    128 .El
    129 .Sh MOUSE ACTIONS
    130 .Bl -tag -width Ds
    131 .It LEFT-CLICK
    132 When inside an existing cropping rectangle, drag it around.
    133 When on one of the edges, resize the rectangle, locking it to that axis.
    134 When on one of the corners, resize the rectangle regardless of axis.
    135 When outside an existing cropping rectangle, replace the current rectangle
    136 with a new one.
    137 .El
    138 .Sh EXIT STATUS
    139 .Ex -std
    140 .Sh EXAMPLES
    141 Normal usage:
    142 .Bd -literal
    143 $ croptool *.jpg > tmp.sh
    144 $ sh tmp.sh
    145 .Ed
    146 .Pp
    147 Or, if you're brave:
    148 .Bd -literal
    149 $ croptool *.jpg | sh
    150 .Ed
    151 .Pp
    152 It is also possible to do more advanced things.
    153 For instance, to save cropped images into a separate directory instead of
    154 overwriting the original images, something like this can be done:
    155 .Bd -literal
    156 $ croptool -f "croptool_crop %wx%h+%l+%t '%f' '/path/to/cropped/%f'" *.jpg | sh
    157 .Ed
    158 .Pp
    159 If more advanced features are needed for the actual cropping (e.g. a
    160 different output format), other tools such as
    161 .Xr convert 1
    162 can be used:
    163 .Bd -literal
    164 $ croptool -f 'convert -crop %wx%h+%l+%t "%f" "$(basename "%f" .jpg).png"' *.jpg | sh
    165 .Ed
    166 .Pp
    167 Note that no great care has been taken to deal with filenames containing
    168 single or double quotes.
    169 That is left as an exercise to the reader (hint: just don't have
    170 filenames containing quotes).
    171 .Sh SEE ALSO
    172 .Xr convert 1 ,
    173 .Xr croptool_crop 1 ,
    174 .Xr mogrify 1 ,
    175 .Xr selectool 1
    176 .Sh AUTHORS
    177 .An lumidify Aq Mt nobody@lumidify.org
    178 .Sh BUGS
    179 The filenames are printed without any escaping, so filenames with
    180 quotes may cause issues depending on the output format.
    181 .Pp
    182 Transparent portions of images should probably be shown differently,
    183 but I'm too lazy to fix that and don't really care at the moment.
    184 .Pp
    185 Since the coordinates of the cropping rectangle are stored as integers,
    186 they will become skewed while resizing.
    187 If this becomes a real problem, though, you're probably doing something
    188 wrong anyways.