Filter images by orientation using Shortcuts / Automator

Some time back I’d built a script that would look through a folder of pictures and grab out a random subset that were in a certain orientation which I could then use as screensavers or other similar uses.

Initially I’d used an Automator action I’d found on Automator World, but that stopped working with Big Sur.

I figured that I’d see if I could resurrect this script now in Shortcuts, but I don’t see anything there as a replacement either. I assume a simple shell script would probably due the trick, as all I want to do is point the step towards a folder of images and simply filter it to only the horizontal or portrait images, but I also want to make sure that whatever I’m doing is fairly efficient since it could be iterating over a few hundred photos in some cases.

Thanks in advance for any suggestions!

Steve

Take a look at Exiftool, I’ve used this in the past to process tens of thousands of images, it’s very fast and if you like scripting then I’m sure you will find what you need.

I took a couple of images that I copied to my desktop and ran the following command-line on them:

exiftool -Orientation -ImageWidth -ImageHeight ~/Desktop/IMG_2488.jpeg
Orientation : Rotate 90 CW
Image Width : 4032
Image Height : 3024

exiftool -Orientation -ImageWidth -ImageHeight ~/Desktop/DSC00313.JPG
Orientation : Horizontal (normal)
Image Width : 1616
Image Height : 1080

http://exiftool.sourceforge.net

1 Like