
ImageMagick: How to Rotate an Image
Updated
Learn how to rotate an image by any angle using ImageMagick

Before we start, make sure you have ImageMagick installed on your computer and your image ready in a folder. If you don't have it yet, run this command:
brew install imagemagick
First, open your terminal and navigate to the folder that has your image. To rotate it, run this command:
magick input.jpg -rotate 90 output.jpg
The -rotate option takes the number of degrees, and 90 turns the image to the right. Just remember to replace input.jpg with your actual filename. To go the other way, use a negative number, like -rotate -90.
For a custom angle, run this command:
magick input.jpg -background black -rotate 45 output.jpg
When the picture is tilted, the canvas gets bigger and the empty corners are filled with the color you set with -background. To make sure everything worked, run open output.jpg and check the result.
One more tip: if a photo comes out sideways from your camera, run magick input.jpg -auto-orient output.jpg and ImageMagick fixes it for you.
