1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Improve on reading dates from XMP sidecars

This commit is contained in:
Martin Kampas 2024-03-01 13:20:09 +01:00
parent 98a78e34fe
commit 03e0822181
2 changed files with 49 additions and 2 deletions

View File

@ -160,10 +160,31 @@ export class MetadataLoader {
}
}
}
let hasPhotoshopDate = false;
if ((sidecarData as SideCar).photoshop !== undefined) {
if ((sidecarData as SideCar).photoshop.DateCreated !== undefined) {
const date = Utils.timestampToMS((sidecarData as SideCar).photoshop.DateCreated, null);
if (date) {
metadata.creationDate = date;
hasPhotoshopDate = true;
}
}
}
if ((sidecarData as SideCar).xmp !== undefined) {
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
metadata.rating = (sidecarData as SideCar).xmp.Rating;
}
if (
!hasPhotoshopDate && (
(sidecarData as SideCar).xmp.CreateDate !== undefined ||
(sidecarData as SideCar).xmp.ModifyDate !== undefined
)
) {
metadata.creationDate =
Utils.timestampToMS((sidecarData as SideCar).xmp.CreateDate, null) ||
Utils.timestampToMS((sidecarData as SideCar).xmp.ModifyDate, null) ||
metadata.creationDate;
}
}
}
}
@ -611,12 +632,30 @@ export class MetadataLoader {
}
}
}
let hasPhotoshopDate = false;
if ((sidecarData as SideCar).photoshop !== undefined) {
if ((sidecarData as SideCar).photoshop.DateCreated !== undefined) {
const date = Utils.timestampToMS((sidecarData as SideCar).photoshop.DateCreated, null);
if (date) {
metadata.creationDate = date;
hasPhotoshopDate = true;
}
}
}
if ((sidecarData as SideCar).xmp !== undefined) {
if ((sidecarData as SideCar).xmp.Rating !== undefined) {
metadata.rating = (sidecarData as SideCar).xmp.Rating;
}
if ((sidecarData as SideCar).xmp.CreateDate) {
metadata.creationDate = Utils.timestampToMS((sidecarData as SideCar).xmp.CreateDate, null);
if (
!hasPhotoshopDate && (
(sidecarData as SideCar).xmp.CreateDate !== undefined ||
(sidecarData as SideCar).xmp.ModifyDate !== undefined
)
) {
metadata.creationDate =
Utils.timestampToMS((sidecarData as SideCar).xmp.CreateDate, null) ||
Utils.timestampToMS((sidecarData as SideCar).xmp.ModifyDate, null) ||
metadata.creationDate;
}
}
}

View File

@ -32,6 +32,7 @@ export interface MediaDimension {
export interface SideCar {
dc?: SideCarDc;
xmp?: SideCarXmp;
photoshop?: SideCarPhotoshop;
}
export interface SideCarDc {
@ -41,6 +42,13 @@ export interface SideCarDc {
export interface SideCarXmp {
Rating?: RatingTypes;
CreateDate?: string;
ModifyDate?: string;
}
export interface SideCarPhotoshop {
// Corresponds to Exif.Photo.DateTimeOriginal. No corresponding key exists in
// the xmp namespace!
DateCreated?: string;
}
export const MediaDTOUtils = {