mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
local orientation on ios is unreliable; prefer remote
This commit is contained in:
parent
0a77a65044
commit
dec514bd6d
2 changed files with 25 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:immich_mobile/entities/exif_info.entity.dart';
|
import 'package:immich_mobile/entities/exif_info.entity.dart';
|
||||||
import 'package:immich_mobile/utils/hash.dart';
|
import 'package:immich_mobile/utils/hash.dart';
|
||||||
|
@ -92,27 +93,19 @@ class Asset {
|
||||||
@ignore
|
@ignore
|
||||||
bool _didUpdateLocal = false;
|
bool _didUpdateLocal = false;
|
||||||
|
|
||||||
@ignore
|
|
||||||
bool get didUpdateLocal => _didUpdateLocal;
|
|
||||||
|
|
||||||
Future<AssetEntity> get localAsync async {
|
Future<AssetEntity> get localAsync async {
|
||||||
final currentLocal = local;
|
final local = this.local;
|
||||||
if (currentLocal == null) {
|
if (local == null) {
|
||||||
throw Exception('Asset $fileName has no local data');
|
throw Exception('Asset $fileName has no local data');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_didUpdateLocal) {
|
final updatedLocal =
|
||||||
return currentLocal;
|
_didUpdateLocal ? local : await local.obtainForNewProperties();
|
||||||
}
|
|
||||||
|
|
||||||
final updatedLocal = _didUpdateLocal
|
|
||||||
? currentLocal
|
|
||||||
: await currentLocal.obtainForNewProperties();
|
|
||||||
if (updatedLocal == null) {
|
if (updatedLocal == null) {
|
||||||
throw Exception('Could not fetch local data for $fileName');
|
throw Exception('Could not fetch local data for $fileName');
|
||||||
}
|
}
|
||||||
|
|
||||||
local = updatedLocal;
|
this.local = updatedLocal;
|
||||||
_didUpdateLocal = true;
|
_didUpdateLocal = true;
|
||||||
return updatedLocal;
|
return updatedLocal;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +235,7 @@ class Asset {
|
||||||
return exifInfo.isFlipped;
|
return exifInfo.isFlipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (didUpdateLocal) {
|
if (_didUpdateLocal && Platform.isAndroid) {
|
||||||
final local = this.local;
|
final local = this.local;
|
||||||
if (local == null) {
|
if (local == null) {
|
||||||
throw Exception('Asset $fileName has no local data');
|
throw Exception('Asset $fileName has no local data');
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -404,12 +405,27 @@ class AssetService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<double> getAspectRatio(Asset asset) async {
|
Future<double> getAspectRatio(Asset asset) async {
|
||||||
if (asset.isLocal) {
|
// platform_manager always returns 0 for orientation on iOS, so only prefer it on Android
|
||||||
|
if (asset.isLocal && Platform.isAndroid) {
|
||||||
await asset.localAsync;
|
await asset.localAsync;
|
||||||
} else if (asset.isRemote) {
|
} else if (asset.isRemote) {
|
||||||
asset = await loadExif(asset);
|
asset = await loadExif(asset);
|
||||||
|
} else if (asset.isLocal) {
|
||||||
|
await asset.localAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
return asset.aspectRatio ?? 1.0;
|
final aspectRatio = asset.aspectRatio;
|
||||||
|
if (aspectRatio != null) {
|
||||||
|
return aspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
final width = asset.width;
|
||||||
|
final height = asset.height;
|
||||||
|
if (width != null && height != null) {
|
||||||
|
// we don't know the orientation, so assume it's normal
|
||||||
|
return width / height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue