1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-26 10:50:29 +02:00

fix(web): aspect ratio for videos (#3023)

This commit is contained in:
Sergey Kondrikov 2023-06-29 16:11:00 +03:00 committed by GitHub
parent 8e6c90e294
commit dca48d7722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,6 +181,14 @@ export function getFileMimeType(file: File): string {
return file.type || (mimeTypes[getFilenameExtension(file.name)] ?? ''); 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 * Returns aspect ratio for the asset
*/ */
@ -189,8 +197,7 @@ export function getAssetRatio(asset: AssetResponseDto) {
let width = asset.exifInfo?.exifImageWidth || 235; let width = asset.exifInfo?.exifImageWidth || 235;
const orientation = Number(asset.exifInfo?.orientation); const orientation = Number(asset.exifInfo?.orientation);
if (orientation) { if (orientation) {
// 6 - Rotate 90 CW, 8 - Rotate 270 CW if (isRotated90CW(orientation) || isRotated270CW(orientation)) {
if (orientation == 6 || orientation == 8) {
[width, height] = [height, width]; [width, height] = [height, width];
} }
} }