How to detect image dimensions and run commands on them?

Posted by Jon on Ask Ubuntu See other posts from Ask Ubuntu or by Jon
Published on 2012-11-23T21:59:09Z Indexed on 2012/11/23 23:21 UTC
Read the original article Hit count: 290

Filed under:
|
|

I have a directory full of images, some of which are portrait-sized instead of landscape-sized, and I want to open the portrait-sized ones with an image editor. I can run the imagemagick command identify and I get an output like something.jpg JPEG 1920x1255 1920x1255+0+0 8-bit DirectClass 159KB 0.000u 0:00.000. How can I have a script interpret this output, i.e. decide which is bigger, the 1920 or the 1255, and then run a command on it if it is?

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about imagemagick