From 62e8afebb89b3343c7ea48d5eedd94d9c84331eb Mon Sep 17 00:00:00 2001 From: Yuriy Date: Mon, 24 Jun 2024 22:34:51 -0400 Subject: [PATCH] aspect ratio calc function --- General-Functions.ahk | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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