Can ImageMagick Convert Rotate Multiple Images at Once?

Using a single execution of the ImageMagick convert command (or the magick command in newer versions) to rotate multiple images at once depends entirely on how you structure the syntax. While a basic convert input.jpg -rotate 90 output.jpg command only handles one image at a time, ImageMagick provides robust batch-processing capabilities. By utilizing wildcards, the mogrify tool, or inline loops, you can efficiently rotate entire directories of images in one go without writing complex scripts.

The Limitation of the Standard Convert Command

The standard convert command is designed for explicit input-to-output operations. If you pass multiple input files to a single convert command with a rotate flag, ImageMagick will attempt to combine or sequence them into a single output file (like a multi-page PDF or an animated GIF), rather than saving them back as individual rotated files.

For example, this command will not work as expected for individual files: convert *.jpg -rotate 90 rotated_*.jpg

Instead of creating individual rotated files, it will likely result in an error or an unexpected combined file.

If your goal is to rotate multiple images in a single command execution, ImageMagick includes a sister tool called mogrify specifically designed for batch processing. It shares the same syntax as convert but applies the operation to each file individually and overwrites the originals.

To rotate all JPEG images in a folder 90 degrees clockwise: mogrify -rotate 90 *.jpg

Note: Because mogrify overwrites the original files, it is highly recommended to back up your images before running the command, or use the -path flag to send the rotated images to a separate output directory: mogrify -path ./rotated_output -rotate 90 *.jpg

Method 2: Using the Modern Magick Tool (v7+)

In ImageMagick version 7 and above, the convert command has been replaced by the unified magick command. You can use magick mogrify to achieve the same single-line batch rotation:

magick mogrify -rotate 270 *.png

Method 3: Using ImageMagick v7 Parentheses for Specific Files

If you are using ImageMagick v7 and only want to process a few specific files into distinct new filenames within a single command execution, you can use setting headers and parentheses to isolate the operations:

magick ( input1.jpg -rotate 90 -write output1.jpg ) ( input2.jpg -rotate 90 -write output2.jpg ) null:

This executes as a single command line process, reading and rotating each image independently before writing them to their respective new destinations.