Filter by image size

I am about to shrink a large number of photo images spread over many directories using mogrify. I would like to filter by two criteria. Whether they are in portrait format or whether they are smaller horizontally than the size I am shrinking to. Is there a method I can use from inside a script? Or perhaps some graphical software that can do the same.

Thanks in advance.

You must probably have a method for each type of image file. A JPEG file does store things (including the width and heighth of the image) different from a GIF or an PNG image (and there are more).

I could offer you ways of finding out for several formats, but would like to know if I can restrict the seaching, for where I have that stored, to a few.

Thanks for the speedy response and your kind offer. All the photos are in JPEG format.

Well, you could look into the JPEG itself (I have a piece of ksh script doing that), but maybe the easiest interface is the program jhead. It can be installed from the OSS repos (the package name is also jhead).

One can manipulate JPEG headers with it, but you only want some information. Calling it without any additional options will give you something like (this is the minimum, there might be much more):

 jhead RASC-Eviii.jpeg 
File name    : RASC-Eviii.jpeg
File size    : 76190 bytes
File date    : 2015:09:18 12:16:16
Resolution   : 584 x 750
JPEG Quality : 75


You are interested in what here is called the Resolution:

jhead RASC-Eviii.jpeg | grep '^Resolution'
Resolution   : 584 x 750

And that is of course a good start for further processing in a script.

This is exactly what I need to get me started. Thanks again