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

playing around

This commit is contained in:
gras 2024-04-16 16:53:24 +02:00
parent 23a05f6b43
commit 10c5ec545e
2 changed files with 50 additions and 31 deletions

View File

@ -1,34 +1,25 @@
//The elements are [tagname1, tag-name1, description]
//The elements are [tagname1, tag-name1]
//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 metadataTags: [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.OffsetTime"], //"Date and time when the image was created"],
["ifd0.ModifyDate", ""], //"Modificaton date from the idf0 section"],
["ihdr.Creation Time", ""], //"PNG Creation Time"],
["photoshop.DateCreated", ""], //"Date and time when the image was created"],
["xmp:CreateDate", ""], //"Date and time when the image was created (XMP standard)"],
["iptc.DateCreated", "iptc.TimeCreated"], //"Date and time when the image was created (IPTC standard)"],
["exif.DateTimeDigitized", "exif.OffsetTimeDigitized"], //"Date and time when the image was digitized"],
["xmp.MetadataDate", ""], //??????????
["TIFF.DateTime", ""], //"Date and time when the image was created (TIFF standard)"],
["quicktime.CreationDate", ""], //"Date and time when the QuickTime movie was created"],
["quicktime.CreateDate", ""], //"Date and time when the QuickTime movie was created in UTC"],
["AVI.CreationTime", ""], //"Date and time when the AVI video was created"],
["MP4.CreationTime", ""], //"Date and time when the MP4 video was created"],
["MP4.ModifyDate", ""], //"Date and time when the MP4 video was last modified"],
["WebP.VP8X/Time", ""], //"Date and time when the WebP image was created"],
["heic.ContentCreateDate", ""], //"Date and time when the HEIC image content was created"],
["heic.CreationDate", ""], //"Date and time when the HEIC image was created"],
["cr2.DateTimeOriginal", ""], //"Date and time when the original Canon RAW image was taken"],
["nef.DateTimeOriginal", ""], //"Date and time when the original Nikon RAW image was taken"],
["dng.DateTimeOriginal", ""], //"Date and time when the original DNG image was taken"],
["rw2.DateTimeOriginal", ""], //"Date and time when the original Panasonic RAW image was taken"],
["arw.DateTimeOriginal", ""], //"Date and time when the original Sony Alpha RAW image was taken"],
["cr3.DateTimeOriginal", ""], //"Date and time when the original Canon RAW image was taken"],
["sr2.DateTimeOriginal", ""], //"Date and time when the original Sony RAW image was taken"],
["orf.DateTimeOriginal", ""], //"Date and time when the original Olympus RAW image was taken"],
["xmp:ModifyDate", ""], //"Date and time when the image was last modified (XMP standard)"]
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.
];

View File

@ -15,6 +15,7 @@ import * as path from 'path';
import { Utils } from '../../../common/Utils';
import { FFmpegFactory } from '../FFmpegFactory';
import { ExtensionDecorator } from '../extension/ExtensionDecorator';
import { DateTags } from './MetadataCreationDate';
const LOG_TAG = '[MetadataLoader]';
const ffmpeg = FFmpegFactory.get();
@ -360,6 +361,33 @@ 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 {
const pathElements = path.split('.');
let currentObject: any = company;
for (const element of pathElements) {
const tmp = currentObject[element];
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 mapTimestampAndOffset(metadata: PhotoMetadata, exif: any) {
metadata.creationDate = Utils.timestampToMS(exif?.photoshop?.DateCreated, null) ||
Utils.timestampToMS(exif?.xmp?.CreateDate, null) ||