mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(mobile): respect orientation on displaying asset dimensions (#13129)
* fix(mobile): respect orientation on displaying asset dimensions * lint --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
31c0dfb681
commit
35bb2e786f
@ -22,8 +22,12 @@ class Asset {
|
|||||||
durationInSeconds = remote.duration.toDuration()?.inSeconds ?? 0,
|
durationInSeconds = remote.duration.toDuration()?.inSeconds ?? 0,
|
||||||
type = remote.type.toAssetType(),
|
type = remote.type.toAssetType(),
|
||||||
fileName = remote.originalFileName,
|
fileName = remote.originalFileName,
|
||||||
height = remote.exifInfo?.exifImageHeight?.toInt(),
|
height = isFlipped(remote)
|
||||||
width = remote.exifInfo?.exifImageWidth?.toInt(),
|
? remote.exifInfo?.exifImageWidth?.toInt()
|
||||||
|
: remote.exifInfo?.exifImageHeight?.toInt(),
|
||||||
|
width = isFlipped(remote)
|
||||||
|
? remote.exifInfo?.exifImageHeight?.toInt()
|
||||||
|
: remote.exifInfo?.exifImageWidth?.toInt(),
|
||||||
livePhotoVideoId = remote.livePhotoVideoId,
|
livePhotoVideoId = remote.livePhotoVideoId,
|
||||||
ownerId = fastHash(remote.ownerId),
|
ownerId = fastHash(remote.ownerId),
|
||||||
exifInfo =
|
exifInfo =
|
||||||
@ -507,3 +511,20 @@ extension AssetsHelper on IsarCollection<Asset> {
|
|||||||
return where().anyOf(ids, (q, String e) => q.localIdEqualTo(e));
|
return where().anyOf(ids, (q, String e) => q.localIdEqualTo(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if this [int] is flipped 90° clockwise
|
||||||
|
bool isRotated90CW(int orientation) {
|
||||||
|
return [7, 8, -90].contains(orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if this [int] is flipped 270° clockwise
|
||||||
|
bool isRotated270CW(int orientation) {
|
||||||
|
return [5, 6, 90].contains(orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if this [Asset] is flipped 90° or 270° clockwise
|
||||||
|
bool isFlipped(AssetResponseDto response) {
|
||||||
|
final int orientation = response.exifInfo?.orientation?.toInt() ?? 0;
|
||||||
|
return orientation != 0 &&
|
||||||
|
(isRotated90CW(orientation) || isRotated270CW(orientation));
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user