Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Consolidate panorama metadata helpers

Neeraj Guptaaaa6d37f5b45
diff --git a/mobile/apps/photos/lib/models/file/file.dart b/mobile/apps/photos/lib/models/file/file.dart
index 371bbd25a8..f2506e673b 100644
--- a/mobile/apps/photos/lib/models/file/file.dart
+++ b/mobile/apps/photos/lib/models/file/file.dart
@@ -215,7 +215,6 @@ class EnteFile {
}
if (mediaUploadData.exifData != null) {
mediaUploadData.isPanorama = checkPanoramaFromEXIF(
- null,
mediaUploadData.exifData,
);
}
diff --git a/mobile/apps/photos/lib/utils/exif_util.dart b/mobile/apps/photos/lib/utils/exif_util.dart
index 68b5315649..932c869b02 100644
--- a/mobile/apps/photos/lib/utils/exif_util.dart
+++ b/mobile/apps/photos/lib/utils/exif_util.dart
@@ -12,7 +12,6 @@ import "package:photos/models/location/location.dart";
import "package:photos/models/metadata/file_magic.dart";
import "package:photos/services/isolated_ffmpeg_service.dart";
import "package:photos/services/location_service.dart";
-import "package:photos/src/rust/api/motion_photo_api.dart";
import 'package:photos/utils/file_util.dart';
import 'package:random_access_source/random_access_source.dart';
@@ -69,10 +68,6 @@ Future<Map<String, IfdTag>?> tryExifFromFile(File originFile) async {
}
}
-Future<Map<String, dynamic>> getXmp(File file) async {
- return extractXmp(filePath: file.path);
-}
-
Future<FFProbeProps?> getVideoPropsAsync(File originalFile) async {
try {
final stopwatch = Stopwatch()..start();
@@ -95,12 +90,6 @@ Future<FFProbeProps?> getVideoPropsAsync(File originalFile) async {
}
}
-bool? checkPanoramaFromEXIF(File? file, Map<String, IfdTag>? exifData) {
- final element = exifData?["EXIF CustomRendered"];
- if (element?.printable == null) return null;
- return element?.printable == "6";
-}
-
class ParsedExifDateTime {
late final DateTime? time;
late final String? dateTime;
diff --git a/mobile/apps/photos/lib/utils/panorama_util.dart b/mobile/apps/photos/lib/utils/panorama_util.dart
index f7bfcb0166..89262d14b8 100644
--- a/mobile/apps/photos/lib/utils/panorama_util.dart
+++ b/mobile/apps/photos/lib/utils/panorama_util.dart
@@ -1,3 +1,6 @@
+import "dart:io";
+
+import "package:exif_reader/exif_reader.dart";
import "package:logging/logging.dart";
import "package:photos/models/file/extensions/file_props.dart";
import "package:photos/models/file/file.dart";
@@ -10,6 +13,10 @@ import "package:photos/utils/file_util.dart";
final _logger = Logger("PanoramaUtil");
+Future<Map<String, dynamic>> getXmp(File file) async {
+ return extractXmp(filePath: file.path);
+}
+
/// Check if the file is a panorama image.
Future<bool> checkIfPanorama(EnteFile enteFile) async {
if (enteFile.fileType != FileType.image) {
@@ -20,24 +27,25 @@ Future<bool> checkIfPanorama(EnteFile enteFile) async {
return false;
}
try {
- final result = await extractXmp(filePath: file.path);
- if (checkPanoramaFromXMP(result)) {
+ final xmpData = await getXmp(file);
+ if (checkPanoramaFromXMP(xmpData)) {
return true;
}
} catch (_) {}
- final result = await readExifAsync(file);
+ final exifData = await readExifAsync(file);
+ return checkPanoramaFromEXIF(exifData) ?? false;
+}
- final element = result["EXIF CustomRendered"];
+bool? checkPanoramaFromEXIF(Map<String, IfdTag>? exifData) {
+ final element = exifData?["EXIF CustomRendered"];
+ if (element?.printable == null) return null;
return element?.printable == "6";
}
bool checkPanoramaFromXMP(Map<String, dynamic> xmpData) {
- if (xmpData["GPano:ProjectionType"] == "cylindrical" ||
- xmpData["GPano:ProjectionType"] == "equirectangular") {
- return true;
- }
- return false;
+ final projectionType = xmpData["GPano:ProjectionType"];
+ return projectionType == "cylindrical" || projectionType == "equirectangular";
}
// guardedCheckPanorama() method is used to check if the file is a panorama image.