Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Rotate An Image With ImageMagick

Code

# white (or possibly black) background
magick mogrify -rotate 45 a.png

# transparent background
magick mogrify -background 'rgba(0,0,0,0)' -rotate 45 a.png

# black background
magick mogrify -background 'rgb(0,0,0)' -rotate 45 a.png
  • Rotates the image 45 degrees clockwise

  • Rotates the image in place (i.e. it updates the file)

  • Expands the canvas to cover the points which extend out on the rotate

  • Puts a white background on area that is expanded