From dca48d7722b690928cf4a3349a015969d73c05a6 Mon Sep 17 00:00:00 2001 From: Sergey Kondrikov Date: Thu, 29 Jun 2023 16:11:00 +0300 Subject: [PATCH] fix(web): aspect ratio for videos (#3023) --- web/src/lib/utils/asset-utils.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/src/lib/utils/asset-utils.ts b/web/src/lib/utils/asset-utils.ts index 0f6c848729..c993b97d76 100644 --- a/web/src/lib/utils/asset-utils.ts +++ b/web/src/lib/utils/asset-utils.ts @@ -181,6 +181,14 @@ export function getFileMimeType(file: File): string { return file.type || (mimeTypes[getFilenameExtension(file.name)] ?? ''); } +function isRotated90CW(orientation: number) { + return orientation == 6 || orientation == 90; +} + +function isRotated270CW(orientation: number) { + return orientation == 8 || orientation == -90; +} + /** * Returns aspect ratio for the asset */ @@ -189,8 +197,7 @@ export function getAssetRatio(asset: AssetResponseDto) { let width = asset.exifInfo?.exifImageWidth || 235; const orientation = Number(asset.exifInfo?.orientation); if (orientation) { - // 6 - Rotate 90 CW, 8 - Rotate 270 CW - if (orientation == 6 || orientation == 8) { + if (isRotated90CW(orientation) || isRotated270CW(orientation)) { [width, height] = [height, width]; } }