How to modify multiple images from the command line?
NicolasBrondinBernard
Resize, convert, and edit as many images as you want in a single command!

Article published on 19/04/2021, last updated on 10/08/2026
Opening your editing software, loading an image, modifying it, and saving it to a new file is an easy operation, but when you repeat it 5 times, 10 times, 100 times, it becomes extremely time-consuming and tedious.
Fortunately, some software offers the ability to create macros or scripts to perform this processing in bulk, but you still have to open the software, load and run the script by hand.
Today we're going to learn how to do the same thing, but using a tool that is both simple and very powerful, directly from the command line.
Discover ImageMagick
ImageMagick is software available on all major operating systems (Linux, MacOS, Windows) used to edit, modify, and create images directly from a terminal.
You can download it directly from the official website: https://imagemagick.org/script/download.php
When you install the software, you get a suite of tools that are independent yet compatible with each other, all bundled under the same executable:
- convert, to convert, resize, crop, blur,... an image
- mogrify, similar to convert but for automating the process on multiple images
- composite, to stack several images on top of each other like layers
- animate, to create an animation based on several images
- and many more!
But ImageMagick is so powerful that it's even possible to generate images from simple command lines. Imagine you wanted to generate default banners based on a user's username, in just a few lines, it's possible!
An example script
To show you how it works, I decided to start with a very common use-case: normalizing the size and format of an entire folder of images.
To do this, I use ImageMagick's mogrify tool, and in a single command line I normalize all the images:
$ magick mogrify -resize 256x256 -path ./destination/ -format jpg ./source/*
- The -resize option indicates the maximum output size of my images (while preserving the ratio)
- The -path option indicates the output folder (which must be created beforehand)
- The -format option indicates the format to which the images will be converted
- The path at the end of the command indicates the source files to convert
To discover all of ImageMagick's possibilities, I invite you to read the official documentation available here: https://imagemagick.org
No spam. Only free content, news, and ever more resources to level up your skills!
Join +1500 developers
ImageMagick
No comments yet