Rotating images with BASH and ImageMagick

I’m on one of our older, Windows 7 computers and need to rotate 12 images 90 degrees clockwise, but I know Adobe Photoshop won’t play well with my 1-bit bitonal scans.

I rotated the images with ImageMagick version 6 in Cygwin’s BASH Shell using 2 short lines of code.

I first created a list of filenames to rotate while looking through images during quality control:

$ list="83 91 93 115 185 193 195 217 385 393 395 417"

With the list saved into memory, I looped over each number, or integer (i), in the list to create a filename zero-spaced to 4-digits. This filename is printed to standard output before the file is rotated with ImageMagick:

$ for i in $list; do filename=$(printf "%04d.tif" $i); echo "filename: $filename"; mogrify -rotate 90 "$filename"; done

Jeremy Moore