mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-21 01:22:08 +02:00
ready to read the data in order
This commit is contained in:
parent
10c5ec545e
commit
5dc1d62863
@ -1,25 +1,25 @@
|
||||
//The elements are [tagname1, tag-name1]
|
||||
//The elements are [tag-name1, tag-name2, type of tag-name2]
|
||||
//tagname1 is typically a full date time, but in some cases tagname1 and tagname2 together make up a full timestamp
|
||||
|
||||
//Interesting exiftool forums posts about some of these tags:
|
||||
//exif.DateTimeOriginal, exif.CreateDate/exif.DateTimeDigitized and exif.ModifyDate: https://exiftool.org/forum/index.php?topic=13170.msg71174#msg71174
|
||||
//https://exiftool.org/forum/index.php?topic=15555.msg83536#msg83536
|
||||
|
||||
const DateTags: [string, string][] = [
|
||||
// Date tag Offset or time tag //Description
|
||||
["exif.DateTimeOriginal", "exif.OffsetTimeOriginal"], //Date and time when the original image was taken - shutter close time
|
||||
["exif.CreateDate", "exif.OffsetTimeDigitized"], //Date and time when the image was created
|
||||
["exif.DateTimeDigitized", "exif.OffsetTimeDigitized"], //Same as exif.CreateDate but older and newer spec name
|
||||
["ifd0.ModifyDate", ""], //The date and time of image creation. In Exif standard, it is the date and time the file was changed.
|
||||
["ihdr.Creation Time", ""], //Time of original image creation for PNG files
|
||||
["photoshop.DateCreated", ""], //The date the intellectual content of the document was created. Used and set by LightRoom among others
|
||||
["xmp:CreateDate", ""], //Date and time when the image was created (XMP standard)
|
||||
["iptc.DateCreated", "iptc.TimeCreated"], //Designates the date and optionally the time the content of the image was created rather than the date of the creation of the digital representation
|
||||
["quicktime.CreationDate", ""], //Date and time when the QuickTime movie was created"],
|
||||
["quicktime.CreateDate", ""], //Date and time when the QuickTime movie was created in UTC"],
|
||||
["heic.ContentCreateDate", ""], //Date and time when the HEIC image content was created"],
|
||||
["heic.CreationDate", ""], //Date and time when the HEIC image was created"],
|
||||
["tiff.DateTime", ""], //Date and time of image creation. This property is stored in XMP as xmp:ModifyDate.
|
||||
["xmp:ModifyDate", "exif.OffsetTime"], //Date and time when the image was last modified (XMP standard)"]
|
||||
["xmp.MetadataDate", ""], //The date and time that any metadata for this resource was last changed. It should be the same as or more recent than xmp:ModifyDate.
|
||||
export const DateTags: [string, string, string][] = [
|
||||
// Date tag Offset or time tag Type //Description
|
||||
["exif.DateTimeOriginal", "exif.OffsetTimeOriginal", 'O'], //Date and time when the original image was taken - shutter close time
|
||||
["exif.CreateDate", "exif.OffsetTimeDigitized", 'O'], //Date and time when the image was created
|
||||
["exif.DateTimeDigitized", "exif.OffsetTimeDigitized", 'O'], //Same as exif.CreateDate but older and newer spec name
|
||||
["ifd0.ModifyDate", undefined, undefined], //The date and time of image creation. In Exif standard, it is the date and time the file was changed.
|
||||
["ihdr.Creation Time", undefined, undefined], //Time of original image creation for PNG files
|
||||
["photoshop.DateCreated", undefined, undefined], //The date the intellectual content of the document was created. Used and set by LightRoom among others
|
||||
["xmp:CreateDate", undefined, undefined], //Date and time when the image was created (XMP standard)
|
||||
["iptc.DateCreated", "iptc.TimeCreated", 'T'], //Designates the date and optionally the time the content of the image was created rather than the date of the creation of the digital representation
|
||||
["quicktime.CreationDate", undefined, undefined], //Date and time when the QuickTime movie was created"],
|
||||
["quicktime.CreateDate", undefined, undefined], //Date and time when the QuickTime movie was created in UTC"],
|
||||
["heic.ContentCreateDate", undefined, undefined], //Date and time when the HEIC image content was created"],
|
||||
["heic.CreationDate", undefined, undefined], //Date and time when the HEIC image was created"],
|
||||
["tiff.DateTime", undefined, undefined], //Date and time of image creation. This property is stored in XMP as xmp:ModifyDate.
|
||||
["xmp:ModifyDate", "exif.OffsetTime", 'O'], //Date and time when the image was last modified (XMP standard)"]
|
||||
["xmp.MetadataDate", undefined, undefined], //The date and time that any metadata for this resource was last changed. It should be the same as or more recent than xmp:ModifyDate.
|
||||
];
|
||||
|
@ -285,6 +285,7 @@ export class MetadataLoader {
|
||||
MetadataLoader.mapKeywords(metadata, exif);
|
||||
MetadataLoader.mapTitle(metadata, exif);
|
||||
MetadataLoader.mapCaption(metadata, exif);
|
||||
MetadataLoader.mapTimestampAndOffset2(metadata, exif);
|
||||
MetadataLoader.mapTimestampAndOffset(metadata, exif);
|
||||
MetadataLoader.mapCameraData(metadata, exif);
|
||||
MetadataLoader.mapGPS(metadata, exif);
|
||||
@ -361,28 +362,23 @@ export class MetadataLoader {
|
||||
metadata.caption = exif.dc?.description?.value || Utils.asciiToUTF8(exif.iptc?.Caption) || metadata.caption || exif.ifd0?.ImageDescription || exif.exif?.UserComment?.value || exif.Iptc4xmpCore?.ExtDescrAccessibility?.value ||exif.acdsee?.notes;
|
||||
}
|
||||
|
||||
private static mapTimestampAndOffset2(metadata: PhotoMetadata, exif: any) {
|
||||
function getValueFromPath(company: Company, path: string): any {
|
||||
// Avoid using eval() due to security risks
|
||||
return eval(`company.${path}`);
|
||||
}
|
||||
function getValueFromPath(company: Company, path: string): any {
|
||||
private static getValue(exif: any, path: string): any {
|
||||
const pathElements = path.split('.');
|
||||
let currentObject: any = company;
|
||||
|
||||
for (const element of pathElements) {
|
||||
const tmp = currentObject[element];
|
||||
let currentObject: any = exif;
|
||||
for (const pathElm of pathElements) {
|
||||
const tmp = currentObject[pathElm];
|
||||
if (tmp === undefined) {
|
||||
// Handle case where path is invalid
|
||||
return undefined;
|
||||
}
|
||||
currentObject = tmp;
|
||||
}
|
||||
|
||||
return currentObject;
|
||||
}
|
||||
for (const [main, extra] of DateTags) {
|
||||
const pathelms[] = main.split["."];
|
||||
}
|
||||
|
||||
private static mapTimestampAndOffset2(metadata: PhotoMetadata, exif: any) {
|
||||
let ts;
|
||||
for (const [mainpath, extrapath, extratype] of DateTags) {
|
||||
ts = MetadataLoader.getValue(exif, mainpath);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user