fix(mobile): correct local asset dimensions (#26677)

* fix(mobile): correct local asset dimensions

We are constraining the size of videos so that they play nicely with
hero animations, and don't stretch in weird ways. This however caused a
regression as we are not account for local assets on Android which have
un-oriented dimensions.

* post-orientation width and height in local sync

* migration

* no need to handle it in asset viewer

---------

Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Thomas
2026-03-07 18:07:34 +00:00
committed by GitHub
parent e73686bd76
commit dd72ec2621
2 changed files with 21 additions and 4 deletions

View File

@@ -185,16 +185,17 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
numericId, rawMediaType, mimeTypeColumn, specialFormatColumn, xmpColumn, c numericId, rawMediaType, mimeTypeColumn, specialFormatColumn, xmpColumn, c
) )
val isFlipped = orientation == 90 || orientation == 270
val asset = PlatformAsset( val asset = PlatformAsset(
id, id,
name, name,
assetType, assetType,
createdAt, createdAt,
modifiedAt, modifiedAt,
width, if (isFlipped) height else width,
height, if (isFlipped) width else height,
duration, duration,
orientation.toLong(), 0L,
isFavorite, isFavorite,
playbackStyle = playbackStyle, playbackStyle = playbackStyle,
) )

View File

@@ -35,7 +35,7 @@ import 'package:isar/isar.dart';
// ignore: import_rule_photo_manager // ignore: import_rule_photo_manager
import 'package:photo_manager/photo_manager.dart'; import 'package:photo_manager/photo_manager.dart';
const int targetVersion = 23; const int targetVersion = 24;
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async { Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
final hasVersion = Store.tryGet(StoreKey.version) != null; final hasVersion = Store.tryGet(StoreKey.version) != null;
@@ -105,6 +105,10 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
await _populateLocalAssetPlaybackStyle(drift); await _populateLocalAssetPlaybackStyle(drift);
} }
if (version < 24 && Store.isBetaTimelineEnabled) {
await _applyLocalAssetOrientation(drift);
}
if (version < 22 && !Store.isBetaTimelineEnabled) { if (version < 22 && !Store.isBetaTimelineEnabled) {
await Store.put(StoreKey.needBetaMigration, true); await Store.put(StoreKey.needBetaMigration, true);
} }
@@ -436,6 +440,18 @@ Future<void> _populateLocalAssetPlaybackStyle(Drift db) async {
} }
} }
Future<void> _applyLocalAssetOrientation(Drift db) {
final query = db.localAssetEntity.update()
..where((filter) => (filter.orientation.equals(90) | (filter.orientation.equals(270))));
return query.write(
LocalAssetEntityCompanion.custom(
width: db.localAssetEntity.height,
height: db.localAssetEntity.width,
orientation: const Variable(0),
),
);
}
AssetPlaybackStyle _toPlaybackStyle(PlatformAssetPlaybackStyle style) => switch (style) { AssetPlaybackStyle _toPlaybackStyle(PlatformAssetPlaybackStyle style) => switch (style) {
PlatformAssetPlaybackStyle.unknown => AssetPlaybackStyle.unknown, PlatformAssetPlaybackStyle.unknown => AssetPlaybackStyle.unknown,
PlatformAssetPlaybackStyle.image => AssetPlaybackStyle.image, PlatformAssetPlaybackStyle.image => AssetPlaybackStyle.image,