mirror of
https://github.com/immich-app/immich.git
synced 2025-05-19 21:01:24 +02:00
* refactor: user entity * chore: rebase fixes * refactor: remove int user Id * refactor: migrate store userId from int to string * refactor: rename uid to id * feat: drift * pr feedback * refactor: move common overrides to mixin --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:immich_mobile/domain/models/exif.model.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
// TODO: Move to repository once all classes are refactored
|
|
abstract final class ExifDtoConverter {
|
|
static ExifInfo fromDto(ExifResponseDto dto) {
|
|
return ExifInfo(
|
|
fileSize: dto.fileSizeInByte,
|
|
description: dto.description,
|
|
orientation: dto.orientation,
|
|
timeZone: dto.timeZone,
|
|
dateTimeOriginal: dto.dateTimeOriginal,
|
|
isFlipped: isOrientationFlipped(dto.orientation),
|
|
latitude: dto.latitude?.toDouble(),
|
|
longitude: dto.longitude?.toDouble(),
|
|
city: dto.city,
|
|
state: dto.state,
|
|
country: dto.country,
|
|
make: dto.make,
|
|
model: dto.model,
|
|
lens: dto.lensModel,
|
|
f: dto.fNumber?.toDouble(),
|
|
mm: dto.focalLength?.toDouble(),
|
|
iso: dto.iso?.toInt(),
|
|
exposureSeconds: _exposureTimeToSeconds(dto.exposureTime),
|
|
);
|
|
}
|
|
|
|
static bool isOrientationFlipped(String? orientation) {
|
|
final value = orientation == null ? null : int.tryParse(orientation);
|
|
if (value == null) {
|
|
return false;
|
|
}
|
|
final isRotated90CW = value == 5 || value == 6 || value == 90;
|
|
final isRotated270CW = value == 7 || value == 8 || value == -90;
|
|
return isRotated90CW || isRotated270CW;
|
|
}
|
|
|
|
static double? _exposureTimeToSeconds(String? s) {
|
|
if (s == null) {
|
|
return null;
|
|
}
|
|
double? value = double.tryParse(s);
|
|
if (value != null) {
|
|
return value;
|
|
}
|
|
final parts = s.split("/");
|
|
if (parts.length == 2) {
|
|
final numerator = double.tryParse(parts.firstOrNull ?? "-");
|
|
final denominator = double.tryParse(parts.lastOrNull ?? "-");
|
|
if (numerator != null && denominator != null) {
|
|
return numerator / denominator;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|