Mac OS Shortcut to filter photos by orientation

Here’s the gist of what I am trying to do:

  1. Start out with a folder of randomly selected photos
  2. Use a shortcut to iterate over the folder’s contents and select, say, 20 photos that are in landscape orientation that I can use as desktop background images.
  3. Move the selected photos into a specified directory

I can figure out steps 1 & 3, but am stuck on step 2. It seems there is a file filter that will allow me to filter images, and within that an option to filter by orientation (using ‘up’, ‘down’, ‘left’, ‘right’, etc.). However that doesn’t seem to get me what I want - no matter which option I choose, photos in both portrait and landscape orientations pass through the filter. I haven’t been able to find a way to truly only filter down to landscape-only photos.

Is there an easy solution that I am missing here? This doesn’t seem to be an unsolvable problem, but I’m stumped on options for Step 2.

Thanks in advance,
Steve

If you have just one image in the folder, when that is found by Shortcuts, what does it think the orientation is if you just reference that and output it in a show result? Does it change if you then use a ‘get image from input’ action on the file and check the orientation?

I’m wondering if Shortcuts is checking the property of the file rather than the property of the image that the file represents.

I would normally check it myself but it is late for me and I’m just about to turn in for the night. :sleeping:

Thanks for the suggestion - I was wondering which metadata it might be reading (the file vs. the image) and if that could be a clue, but wasn’t sure how to tell - your suggestion was a good idea. However, while I hadn’t had it set up that way, now I do and it still seeing odd behaviors on my end.

For the moment my flow is set up to loop through the pictures with a step that will open the files in preview that trigger a certain condition. I continue to see pictures in both landscape and portrait orientations that are being opened. I realize that I don’t understand those options (up, down, left, right, mirrored, etc.) - are those supposed to relate to portrait vs. landscape?

Thanks again for any help or suggestions,
Steve

You can use shortcuts to get the width and height of a photo and compare them to determine the orientation of a photo. Here’s a quick demo:

https://www.icloud.com/shortcuts/a466ff1ea94c451d9a30f1bf8fb28915

This gets the width and height and divides them. If the result is greater than 1, the photo is in landscape. Otherwise, it’s in portrait (or square, but let’s not worry about that for now).

In addition, if you need photos of a specific aspect ratio, you can find the ratio in decimal and use this logic to filter those images out.

Those options sound suspiciously like display options (e.g., take a look at this article on Preview).

On that basis, I would have to agree that calculating the aspect ratio between the sides is the way to go as suggested above.

2 Likes