Another command line vs. GUI round

I am facing, right now, a task that is paradigmatic of when a GUI ([[Graphical user interface]]) would be preferable over a [[command line interface]]: cropping a picture to extract a fragment (a face in a bigger picture, more precisely).

One would, of course, open [[GIMP]], select the area to cut, then “save as”, e voilà! Sort of. First, starting GIMP is not incredibly fast. Then, you have to:

  1. Select the “Selection” tool (with the mouse! That’s so slow)
  2. Use the tool to select the region (with the mouse!)
  3. Open the “Edit” menu (right click)
  4. Choose “Copy” (with the mouse!)
  5. Open the menu again, and choose “Paste selection as new” (with the… you get it)
  6. Go to the newly opened picture, then “Save as”
  7. Introduce name
  8. Accept in the “Export” menu, when prompted about some transparency thingie
  9. Choose some JPG parameters, like quality
  10. Close GIMP

Of course, if you don’t like the result, you have to repeat everything. Then you will realize that the resulting file is too big, and will use [[ImageMagick]] to reduce it.

After doing the above, y resorted to convert, the tool of the [[ImageMagick]] suite that has save my *ss more times than I can count.

With convert, you write a (apparently cryptic and complex) command line once, and then you can reuse it. Cropping a region of an image blindly seems highly problematic, but it isn’t. You just choose a width, height and (x,y) position of top corner and run. If the result is too wide or whatever, you just rerun the command (hitting once the “up” arrow of the keyboard to rescue the last command, then modify at will).

The command line I am using:

convert source_image -crop WxH+x+y cropped_image && display -resize 50% cropped_image

After just a couple of runs (modifying W, H, x and y depending on the previous run), I obtained the desired result.

Leave a Comment