Ubuntu – Rotate images from terminal

command lineimage processingscriptsshotwell

I have a directory with a lots of images but they are in the wrong orientation. I want to rotate the images to correct the orientation (mostly ±90o). Using image (shotwell photo) viewer I can rotate them individually by clicking the rotate button but that's too tedious.

I looked at man shotwell and shotwell --help-all but there's nothing that explains how to invoke the rotate command from the command line.

Is there any way I can invoke the rotate command of shotwell (or any other viewer) from the terminal? Or any other methods to rotate images are welcome too.

Best Answer

If you're looking for a pure bash implementation, ImageMagick's convert command is what you're looking for:

for szFile in /path/*.png
do 
    convert "$szFile" -rotate 90 /tmp/"$(basename "$szFile")" ; 
done

Above will leave existing files intact and copy the newly rotated ones to /tmp so you can move or copy them somewhere else or even replace the existing ones after the conversion and after verification.

(and it'll work on all recent releases of Ubuntu as it's standard software)

Related Question