mirror of
https://github.com/immich-app/immich.git
synced 2026-03-22 11:00:10 +03:00
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:
@@ -185,16 +185,17 @@ open class NativeSyncApiImplBase(context: Context) : ImmichPlugin() {
|
||||
numericId, rawMediaType, mimeTypeColumn, specialFormatColumn, xmpColumn, c
|
||||
)
|
||||
|
||||
val isFlipped = orientation == 90 || orientation == 270
|
||||
val asset = PlatformAsset(
|
||||
id,
|
||||
name,
|
||||
assetType,
|
||||
createdAt,
|
||||
modifiedAt,
|
||||
width,
|
||||
height,
|
||||
if (isFlipped) height else width,
|
||||
if (isFlipped) width else height,
|
||||
duration,
|
||||
orientation.toLong(),
|
||||
0L,
|
||||
isFavorite,
|
||||
playbackStyle = playbackStyle,
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@ import 'package:isar/isar.dart';
|
||||
// ignore: import_rule_photo_manager
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
|
||||
const int targetVersion = 23;
|
||||
const int targetVersion = 24;
|
||||
|
||||
Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||
final hasVersion = Store.tryGet(StoreKey.version) != null;
|
||||
@@ -105,6 +105,10 @@ Future<void> migrateDatabaseIfNeeded(Isar db, Drift drift) async {
|
||||
await _populateLocalAssetPlaybackStyle(drift);
|
||||
}
|
||||
|
||||
if (version < 24 && Store.isBetaTimelineEnabled) {
|
||||
await _applyLocalAssetOrientation(drift);
|
||||
}
|
||||
|
||||
if (version < 22 && !Store.isBetaTimelineEnabled) {
|
||||
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) {
|
||||
PlatformAssetPlaybackStyle.unknown => AssetPlaybackStyle.unknown,
|
||||
PlatformAssetPlaybackStyle.image => AssetPlaybackStyle.image,
|
||||
|
||||
Reference in New Issue
Block a user