mirror of
https://github.com/immich-app/immich.git
synced 2025-07-07 18:24:10 -04:00
refactor: move exif search from aspect ratio to orientation
This commit is contained in:
parent
4d1d902773
commit
0a77a65044
@ -174,33 +174,17 @@ class Asset {
|
|||||||
|
|
||||||
int stackCount;
|
int stackCount;
|
||||||
|
|
||||||
/// Aspect ratio of the asset
|
|
||||||
/// Returns null if the asset has no sync access to the exif info
|
/// Returns null if the asset has no sync access to the exif info
|
||||||
@ignore
|
@ignore
|
||||||
double? get aspectRatio {
|
double? get aspectRatio {
|
||||||
late final double? orientatedWidth;
|
final orientatedWidth = this.orientatedWidth;
|
||||||
late final double? orientatedHeight;
|
final orientatedHeight = this.orientatedHeight;
|
||||||
|
|
||||||
if (exifInfo != null) {
|
|
||||||
orientatedWidth = this.orientatedWidth?.toDouble();
|
|
||||||
orientatedHeight = this.orientatedHeight?.toDouble();
|
|
||||||
} else if (didUpdateLocal) {
|
|
||||||
final currentLocal = local;
|
|
||||||
if (currentLocal == null) {
|
|
||||||
throw Exception('Asset $fileName has no local data');
|
|
||||||
}
|
|
||||||
orientatedWidth = currentLocal.orientatedWidth.toDouble();
|
|
||||||
orientatedHeight = currentLocal.orientatedHeight.toDouble();
|
|
||||||
} else {
|
|
||||||
orientatedWidth = null;
|
|
||||||
orientatedHeight = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orientatedWidth != null &&
|
if (orientatedWidth != null &&
|
||||||
orientatedHeight != null &&
|
orientatedHeight != null &&
|
||||||
orientatedWidth > 0 &&
|
orientatedWidth > 0 &&
|
||||||
orientatedHeight > 0) {
|
orientatedHeight > 0) {
|
||||||
return orientatedWidth / orientatedHeight;
|
return orientatedWidth.toDouble() / orientatedHeight.toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -249,13 +233,49 @@ class Asset {
|
|||||||
@ignore
|
@ignore
|
||||||
set byteHash(List<int> hash) => checksum = base64.encode(hash);
|
set byteHash(List<int> hash) => checksum = base64.encode(hash);
|
||||||
|
|
||||||
|
/// Returns null if the asset has no sync access to the exif info
|
||||||
@ignore
|
@ignore
|
||||||
int? get orientatedWidth =>
|
@pragma('vm:prefer-inline')
|
||||||
exifInfo != null && exifInfo!.isFlipped ? height : width;
|
bool? get isFlipped {
|
||||||
|
final exifInfo = this.exifInfo;
|
||||||
|
if (exifInfo != null) {
|
||||||
|
return exifInfo.isFlipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (didUpdateLocal) {
|
||||||
|
final local = this.local;
|
||||||
|
if (local == null) {
|
||||||
|
throw Exception('Asset $fileName has no local data');
|
||||||
|
}
|
||||||
|
return local.orientation == 90 || local.orientation == 270;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns null if the asset has no sync access to the exif info
|
||||||
@ignore
|
@ignore
|
||||||
int? get orientatedHeight =>
|
@pragma('vm:prefer-inline')
|
||||||
exifInfo != null && exifInfo!.isFlipped ? width : height;
|
int? get orientatedHeight {
|
||||||
|
final isFlipped = this.isFlipped;
|
||||||
|
if (isFlipped == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFlipped ? width : height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns null if the asset has no sync access to the exif info
|
||||||
|
@ignore
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
int? get orientatedWidth {
|
||||||
|
final isFlipped = this.isFlipped;
|
||||||
|
if (isFlipped == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isFlipped ? height : width;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(other) {
|
bool operator ==(other) {
|
||||||
|
@ -50,6 +50,7 @@ class ExifInfo {
|
|||||||
bool? _isFlipped;
|
bool? _isFlipped;
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
bool get isFlipped => _isFlipped ??= _isOrientationFlipped(orientation);
|
bool get isFlipped => _isFlipped ??= _isOrientationFlipped(orientation);
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
|
@ -15,10 +15,10 @@ class FileInfo extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final textColor = context.isDarkTheme ? Colors.white : Colors.black;
|
final textColor = context.isDarkTheme ? Colors.white : Colors.black;
|
||||||
|
|
||||||
|
final height = asset.orientatedHeight ?? asset.height;
|
||||||
|
final width = asset.orientatedWidth ?? asset.width;
|
||||||
String resolution =
|
String resolution =
|
||||||
asset.orientatedHeight != null && asset.orientatedWidth != null
|
height != null && width != null ? "$height x $width " : "";
|
||||||
? "${asset.orientatedHeight} x ${asset.orientatedWidth} "
|
|
||||||
: "";
|
|
||||||
String fileSize = asset.exifInfo?.fileSize != null
|
String fileSize = asset.exifInfo?.fileSize != null
|
||||||
? formatBytes(asset.exifInfo!.fileSize!)
|
? formatBytes(asset.exifInfo!.fileSize!)
|
||||||
: "";
|
: "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user