ImageMagick Tutorial: How To Batch Crop Images on the Command Line

ImageMagick Tutorial: How To Batch Crop Images on the Command Line

Let’s say you’re writing a series of tutorials on Blender and you’re using the PrintScreen key to take screen shots. PrintScreen is great, but it grabs everything. You probably don’t want your application dock appearing in every image. And you probably don’t want to edit dozens of images manually. You’re in luck! ImageMagick has an easy to use crop function that you can quickly and easily execute from the command line.

If you don’t already have it installed, get ImageMagick the easy way:

Place all of the images you want to crop in a directory and navigate to that directory via command line. In the example I’m using here, I want to trim the bottom 25 pixels from a series of .png’s. I run the following command to do so:

The -format png option states that I want my output file in the .png format. The -gravity south option states that I want the crop to start at the bottom of my image. The -chop 0x25 states that I want to cut 25 pixels from the height. The *.png states that I want these actions to be applied to every .png file in the current directory. Below is my original file:

Screenshot from 2013-10-28 13:43:49

And the freshly trimmed image:

20131028_imageMagickCropTutorial-1

About the Author

ImageMagick Tutorial: How To Batch Crop Images on the Command Line was posted by on . Jared is one half of the creative force behind Dototot. In addition to writing scripts and tutorials, he draws and animates both the digital and the analog.

Discuss this article in the Comments below, or and it with your friends. Learn more about , , and our creative process by subscribing to the New Moon Newsletter .

Recommended for you
Join the discussion

Subscribe to our New Moon Newsletter

How do you make money doing what you love? Sign up for monthly emails exploring the necessary evils of business as we develop a creative media studio using free and open source software.

The email entered is invalid
×