mirror of
https://github.com/immich-app/immich.git
synced 2025-07-03 21:40:00 +02:00
fix(web): show w x h correctly when media is rotated (#9435)
This commit is contained in:
parent
5985f72643
commit
b7ebf3152f
2 changed files with 19 additions and 5 deletions
web/src/lib/utils
|
@ -218,14 +218,18 @@ function isRotated270CW(orientation: number) {
|
|||
return orientation === 7 || orientation === 8 || orientation === -90;
|
||||
}
|
||||
|
||||
export function isFlipped(orientation?: string | null) {
|
||||
const value = Number(orientation);
|
||||
return value && (isRotated270CW(value) || isRotated90CW(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns aspect ratio for the asset
|
||||
*/
|
||||
export function getAssetRatio(asset: AssetResponseDto) {
|
||||
let height = asset.exifInfo?.exifImageHeight || 235;
|
||||
let width = asset.exifInfo?.exifImageWidth || 235;
|
||||
const orientation = Number(asset.exifInfo?.orientation);
|
||||
if (orientation && (isRotated90CW(orientation) || isRotated270CW(orientation))) {
|
||||
if (isFlipped(asset.exifInfo?.orientation)) {
|
||||
[width, height] = [height, width];
|
||||
}
|
||||
return { width, height };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue