Command line to automatically crop an image

cropgimpimagemagick

By using Gimp's menu, you can automatically crop the image (removing white borders). I have a lot of images with white borders of different sizes. I want to remove them using Gimp in command line but I cannot figure out what the command is.

Anyone has an idea?

Maybe by using ImageMagick?

Best Answer

(Mainly for personal future reference,) using ImageMagick:

convert -trim image.jpg image.jpg

To trim/autocrop the whole directory:

for a in *.jpg; do convert -trim "$a" "$a"; done

Or using find:

find -name "*.jpg" -exec convert -trim "{}" "{}" \;
Related Question