From 9e7acc46c10fc3b939d7c2bf4ebc3e25328ba06b Mon Sep 17 00:00:00 2001 From: gras Date: Sat, 30 Mar 2024 15:31:16 +0100 Subject: [PATCH] gps coordinate undefined check + rating update --- src/backend/model/fileaccess/MetadataLoader.ts | 17 +++++++++++++++-- src/common/entities/MediaDTO.ts | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/backend/model/fileaccess/MetadataLoader.ts b/src/backend/model/fileaccess/MetadataLoader.ts index dd812392..bce339f2 100644 --- a/src/backend/model/fileaccess/MetadataLoader.ts +++ b/src/backend/model/fileaccess/MetadataLoader.ts @@ -462,8 +462,12 @@ export class MetadataLoader { metadata.positionData.GPSData.longitude = Utils.isFloat32(exif.gps?.longitude) ? exif.gps.longitude : Utils.xmpExifGpsCoordinateToDecimalDegrees(exif.exif.GPSLongitude); metadata.positionData.GPSData.latitude = Utils.isFloat32(exif.gps?.latitude) ? exif.gps.latitude : Utils.xmpExifGpsCoordinateToDecimalDegrees(exif.exif.GPSLatitude); - metadata.positionData.GPSData.longitude = parseFloat(metadata.positionData.GPSData.longitude.toFixed(6)) - metadata.positionData.GPSData.latitude = parseFloat(metadata.positionData.GPSData.latitude.toFixed(6)) + if (metadata.positionData.GPSData.longitude !== undefined) { + metadata.positionData.GPSData.longitude = parseFloat(metadata.positionData.GPSData.longitude.toFixed(6)) + } + if (metadata.positionData.GPSData.latitude !== undefined) { + metadata.positionData.GPSData.latitude = parseFloat(metadata.positionData.GPSData.latitude.toFixed(6)) + } } } catch (err) { Logger.error(LOG_TAG, 'Error during reading of GPS data: ' + err); @@ -511,6 +515,15 @@ export class MetadataLoader { exif.xmp.Rating !== undefined) { metadata.rating = exif.xmp.Rating; } + if (metadata.rating !== undefined) { + if (metadata.rating < -1) { //Rating -1 means "rejected" according to adobe's spec + metadata.rating = -1; + } else if (metadata.rating > 5) { + metadata.rating = 5; + } + } //else { + //metadata.rating = 0; //Rating 0 means "unrated" according to adobe's spec + //} } private static mapFaces(metadata: PhotoMetadata, exif: any, orientation: number) { diff --git a/src/common/entities/MediaDTO.ts b/src/common/entities/MediaDTO.ts index 92807a39..5be288a4 100644 --- a/src/common/entities/MediaDTO.ts +++ b/src/common/entities/MediaDTO.ts @@ -11,7 +11,7 @@ export interface MediaDTO extends FileDTO { missingThumbnails?: number; } -export type RatingTypes = 0 | 1 | 2 | 3 | 4 | 5; +export type RatingTypes = -1 | 0 | 1 | 2 | 3 | 4 | 5; export interface MediaMetadata { size: MediaDimension;