Is there a straightforward way to only mogrify/convert images whose dimensions are larger than 1080x1920?
The details:
I have directories and subdirectories with many JPEGs of varying dimensions. I have a great mogrify command that adjusts and resizes those images down to 1080x1920, and I'm happy with the results.
Code: Select all
find * -iname '*.jpg' -print0 | xargs -0 mogrify -contrast-stretch .3%,99.7% -resize 1080x1920\> -monitor -quality 80
There are two problems with this:
1) regardless of the dimensions of the image, mogrify will still apply the contrast-stretch
2) regardless of whether the image needs resizing, mogrify will rewite (and thus recompress) the file, losing quality
What I'd like is for mogrify to completely ignore any image under 1080x1920 and not process it at all. I can get the dimensions of the image by using identify, but there doesn't seem to be any way to make use of that information short of grep. Is there any way to have identify or another tool pipe a list of only images above 1080x1920? I'm on OS X and AppleScript through Image Events actually has an easy way to do this, where a script can read an image's dimensions and then test if they are greater than or less than some amount, but I'd like something more portable.