Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

fix(video-upload-cache): implement calculateAspectRatio with GCD

theurzild6f8a1753f42
diff --git a/lib/video-upload-cache.ts b/lib/video-upload-cache.ts
index ed99ac6..36bf1d3 100644
--- a/lib/video-upload-cache.ts
+++ b/lib/video-upload-cache.ts
@@ -61,8 +61,11 @@ async function openDB(): Promise<IDBDatabase> {
}
-function calculateAspectRatio(_width: number, _height: number): string {
- return "auto";
+function calculateAspectRatio(width: number, height: number): string {
+ if (!width || !height) return "auto";
+ const gcd = (a: number, b: number): number => (b === 0 ? a : gcd(b, a % b));
+ const divisor = gcd(width, height);
+ return `${width / divisor}/${height / divisor}`;
}
async function getVideoMetadata(file: File): Promise<{