diff --git a/General-Functions.ahk b/General-Functions.ahk index 0125bbe..be265b9 100644 --- a/General-Functions.ahk +++ b/General-Functions.ahk @@ -605,6 +605,22 @@ GetDateOrdinalSuffix(D) { } +; Calculate the aspect ratio of a video/image using the width + height +getAspectRatio(width, height) { + gcd := gcdFunc(width, height) + return round(width/gcd) ":" round(height/gcd) +} + +; The gcdFunc() is a helper function that calculates the GCD (greatest common divisor) of two numbers using the Euclidean algorithm. +; Used for calculating aspect ratio of Videos +gcdFunc(a, b) { + while b + t := b, b := Mod(a, b), a := t + return a +} + + + ; OnMsgbox - Custom Msgbox Screens