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

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

Let’s say you’re writing a series of Blender tutorials and you’re using PrintScreen to grab screen shots. Unfortunately, this gives you a Pictures directory filled with massive images not optimized for uploading to, and displaying on, a web page. The last thing you want to do is resize them manually. You’re in luck! With the ImageMagick -resize option, you can quickly and easily batch scale those images to a manageable size.

Place all the images you want to scale in a directory and navigate to that location via command line. Then enter:

mogrify -resize 960x528 *.png

This command resizes all of the .png files in your directory to a size of 960 pixels by 528 pixels. Perhaps the height isn’t as important as the width. You can simply enter:

mogrify -resize 960 *.png

This will scale all of your images to a width of 960 pixels, the height will be scaled accordingly, preserving the aspect ratio. Perhaps you have a height and width you are aiming for, but want to preserve the aspect ratio. You can enter:

mogrify -resize 960x528! *.png

When and where possible this will scale your images to 960 by 528 pixels, but will preserve the aspect ratio of those images that won’t scale to these dimensions exactly.

About the Author

ImageMagick Tutorial: How To Batch Resize 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
  • kerry

    on Ubuntu the command “mogrify -resize 960×528! *.png” skews the aspect ratio.
    Also I believe ‘convert’ is same as ‘mogrify’ except it won’t overwrite your files, so better to experiment with that first.
    Don’t mean to nitpick, but they seemed like important points, and this article came up first on Google.

  • Dennis G Daniels

    Many thanks for posting! @disqus_MrDqAgbAmU:disqus you are right “mogrify -resize 960×528! *.png” does skew…

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