Search code examples
imagemagick

Selectively rotate vertical images


I have a directory of images, some of which are vertical (height x width) 7 x 5 while others are horizontal 5 x 7. I'd like to use imagemagick (or other tool) to rotate only the verical images to horizontal. Is this possible to do with imagemagick?


Solution

  • As per http://www.imagemagick.org/script/command-line-options.php#rotate, you can conditionally rotate images:

    convert input.jpg -rotate "90<" output.jpg
    

    This will only rotate, clockwise by 90 degrees, if the height exceeds the width (what you described as a "vertical" image, widely known as portrait orientation).