How to Rotate Pictures from Command Line

command linegimpimagemagick

I have a large set of JPEG pictures all with the same resolution. It would take too long to open each one inside the graphical interface of imagemagic or gimp.

How do I achieve each picture being rotated and saved as the same filename?

Best Answer

You can use the convert command:

convert input.jpg -rotate <angle in degrees> out.jpg

To rotate 90 degrees clockwise:

convert input.jpg -rotate 90 out.jpg

To save the file with the same name:

convert file.jpg -rotate 90 file.jpg

To rotate all files:

for photo in *.jpg ; do convert $photo -rotate 90 $photo ; done

Alternatively, you can also use the mogrify command line tools (the best tool) recommended by @don-crissti:

mogrify -rotate 90 *.jpg
Related Question