ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: StarGeek on May 31, 2016, 07:36:55 PM

Title: Aspect Ratio config file
Post by: StarGeek on May 31, 2016, 07:36:55 PM
After reading a post on Reddit where someone wanted to find files that weren't a certain aspect ratio, I was curious as to what could be done with Exiftool.  A quick google brought up some code and I was able to make a config file out of it.  It finds the lowest common denominator and uses that to get the lowest integer ratio.  No decimals involved, so if you want to find something like 2.35:1, you'll have to figure something else out.

Sample output
======== X:/!temp/Test4.jpg
Aspect Ratio                    : 1749:1205
Image Size                      : 1749x1205
======== X:/!temp/Test4.mp4
Aspect Ratio                    : 16:9
Image Size                      : 1280x720
======== X:/!temp/RCNX0001.JPG
Aspect Ratio                    : 16:9
Image Size                      : 3776x2124
======== X:/!temp/IMGP0852.jpg
Aspect Ratio                    : 4:3
Image Size                      : 2592x1944
======== X:/!temp/IMG_0938.JPG
Aspect Ratio                    : 1:1
Image Size                      : 59x59
    5 image files read
Title: Re: Aspect Ratio config file
Post by: Phil Harvey on May 31, 2016, 09:04:58 PM
Interesting math.  Looks like fun.  Don't tell me why it works... I want to figure it out myself when I get a chance. :)

- Phil
Title: Re: Aspect Ratio config file
Post by: StarGeek on May 31, 2016, 09:29:09 PM
Quote from: Phil Harvey on May 31, 2016, 09:04:58 PM
Don't tell me why it works... I want to figure it out myself when I get a chance. :)

I have no idea how it works, but it's apparently Euclid's algorithm (https://en.wikipedia.org/wiki/Euclidean_algorithm).  As usual, I just copied the code from elsewhere.