2

I was trying to rotate few hundred images which have 7000px height in 1000+ images how to rotate them from bash.

0

1 Answer 1

3

You can analyse the size of the picture using ImageMagick's identify and then rotate it using ImageMagick's convert commandline tool.

pic=file.jpg
height=$(identify ${pic} | sed 's/.*x\([0-9]\+\)\+.*/\1/g')

if [[ $height -gt 7000 ]]; then
  convert ${pic} -rotate 90 ${pic}_rotated
fi

The second line extract the height from the output of indentify. The if-clause check if that value is greater than 7000 and then rotates the image 90°.

1
  • 4
    No need for sed, just user -format option to output only image height: identify -format "%h" Commented Feb 13, 2015 at 9:30

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.