The ImageMagick command to crop all images in a directory

If you ever want to use ImageMagick to crop a bunch of images that are in one directory, I can confirm that this command crops all the JPG images in the current folder while creating new JPG files with the new name shown:

for img in *.jpg; do
    magick "$img" -crop 1006x810+350+250 "cropped_$img"
done

The ImageMagick command inside the for loop shows the actual cropping command, and the sizes shown have to do with the collection of images I’m working on today. Specifically, I’m cropping each image from the upper-left coordinate of (350, 250) to the lower-right coordinate of (1356, 1060).

One thing I had to do here was to calculate the width and height of the crop area:

  • Width: 1356 - 350 = 1006
  • Height: 1060 - 250 = 810

Then I used those values to create the cropping command I showed.