imagemagick Rotate Image

mogrify -rotate 90 file.jpg

or

convert -rotate 90 original_file.jpg new_file.jpg

(mogrify overwrites the original image file, whereas, convert writes to a different image file)

Empty triangles in the corners, left over from rotating the image, are filled with the background color (white if no color is specified).

mogrify -rotate 90 -background "#779DF2" file.jpg

http://www.imagemagick.org/script/command-line-options.php#rotate

http://www.imagemagick.org/script/color.php

Auto rotate based on EXIF meta-data

convert -auto-orient original_file.jpg new_file.jpg