Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selectively rotate vertical images

Tags:

imagemagick

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?

like image 521
turtle Avatar asked Sep 20 '25 01:09

turtle


1 Answers

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).

like image 54
Cobra_Fast Avatar answered Sep 23 '25 10:09

Cobra_Fast