Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata mapping and consolidation #868

Merged
merged 7 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test/e2e/**/*.js
test/e2e/**/*.js.map
test/*.js
test/*.js.map
test/tmp/*
benchmark/**/*.js
benchmark/**/*.js.map
gulpfile.js
Expand Down
771 changes: 349 additions & 422 deletions src/backend/model/fileaccess/MetadataLoader.ts

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ export class Utils {
return Date.parse(formattedTimestamp);
}

//function to extract offset string from timestamp string, returns undefined if timestamp does not contain offset
static timestampToOffsetString(timestamp: string) {
try {
const idx = timestamp.indexOf("+");
if (idx > 0) {
return timestamp.substring(idx, timestamp.length);
}
if (timestamp.indexOf("Z") > 0) {
return '+00:00';
}
return undefined;
} catch (err) {
return undefined;
}
}

//function to calculate offset from exif.exif.gpsTimeStamp or exif.gps.GPSDateStamp + exif.gps.GPSTimestamp
static getTimeOffsetByGPSStamp(timestamp: string, gpsTimeStamp: string, gps: any) {
let UTCTimestamp = gpsTimeStamp;
Expand Down Expand Up @@ -383,11 +399,14 @@ export class Utils {
}

public static xmpExifGpsCoordinateToDecimalDegrees(text: string): number {
if (!text) {
return undefined;
}
const parts = text.match(/^([0-9]+),([0-9.]+)([EWNS])$/);
const degrees: number = parseInt(parts[1], 10);
const minutes: number = parseFloat(parts[2]);
const sign = (parts[3] === "N" || parts[3] === "E") ? 1 : -1;
return sign * (degrees + (minutes / 60.0))
return (sign * (degrees + (minutes / 60.0)))
}
}

Expand Down
28 changes: 0 additions & 28 deletions src/common/entities/MediaDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,6 @@ export interface MediaDimension {
height: number;
}

export interface SideCar {
exif?: SideCarExif;
dc?: SideCarDc;
xmp?: SideCarXmp;
photoshop?: SideCarPhotoshop;
}

export interface SideCarExif {
GPSLatitude?: string;
GPSLongitude?: string;
}

export interface SideCarDc {
subject?: string[];
}

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 = {
hasPositionData: (media: MediaDTO): boolean => {
return (
Expand Down
1 change: 0 additions & 1 deletion test/backend/assets/Chars.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"keywords": [
],
"rating": 0,
"faces": [
{
"box": {
Expand Down
1 change: 0 additions & 1 deletion test/backend/assets/Chars_exiftool.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"keywords": [
],
"rating": 0,
"faces": [
{
"box": {
Expand Down
4 changes: 2 additions & 2 deletions test/backend/assets/sidecar/20240107_110258.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
"latitude": 50.089587,
"longitude": 14.39741
}
},
"rating": 3
Expand Down
4 changes: 2 additions & 2 deletions test/backend/assets/sidecar/20240121_102400.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
"latitude": 50.089587,
"longitude": 14.39741
}
},
"rating": 3
Expand Down
10 changes: 8 additions & 2 deletions test/backend/assets/sidecar/20240128_105420.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
"keywords": [
"Travel"
],
"rating": 3
}
"rating": 3,
"positionData": {
"GPSData": {
"latitude": 50.089587,
"longitude": 14.39741
}
}
}
10 changes: 8 additions & 2 deletions test/backend/assets/sidecar/20240128_120909.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
"keywords": [
"Travel"
],
"rating": 3
}
"rating": 3,
"positionData": {
"GPSData": {
"latitude": 50.089587,
"longitude": 14.39741
}
}
}
4 changes: 2 additions & 2 deletions test/backend/assets/sidecar/20240128_185808.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
],
"positionData": {
"GPSData": {
"latitude": 50.08958748333333,
"longitude": 14.397409516666666
"latitude": 50.089587,
"longitude": 14.39741
}
},
"rating": 3
Expand Down
Binary file added test/backend/assets/sidecar/Chars.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
172 changes: 172 additions & 0 deletions test/backend/assets/sidecar/Chars.jpg.xmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.69'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
xmlns:Iptc4xmpCore='http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'>
<Iptc4xmpCore:CountryCode>SWE</Iptc4xmpCore:CountryCode>
<Iptc4xmpCore:Location>Jönköping</Iptc4xmpCore:Location>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:Iptc4xmpExt='http://iptc.org/std/Iptc4xmpExt/2008-02-29/'>
<Iptc4xmpExt:PersonInImage>
<rdf:Bag>
<rdf:li>æÆøØåÅéÉüÜäÄöÖïÏñÑ</rdf:li>
<rdf:li>abcdefghijklmnopqrstuvwxyz</rdf:li>
<rdf:li>abcdefghijklmnopqrstuvwxyz</rdf:li>
</rdf:Bag>
</Iptc4xmpExt:PersonInImage>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:MP='http://ns.microsoft.com/photo/1.2/'
xmlns:MPRI='http://ns.microsoft.com/photo/1.2/t/RegionInfo#'
xmlns:MPReg='http://ns.microsoft.com/photo/1.2/t/Region#'>
<MP:RegionInfo rdf:parseType='Resource'>
<MPRI:Regions>
<rdf:Bag>
<rdf:li rdf:parseType='Resource'>
<MPReg:PersonDisplayName>æÆøØåÅéÉüÜäÄöÖïÏñÑ</MPReg:PersonDisplayName>
<MPReg:Rectangle>0.294791666666667, 0.13287037037037, 0.107291666666667, 0.237962962962963</MPReg:Rectangle>
</rdf:li>
<rdf:li rdf:parseType='Resource'>
<MPReg:PersonDisplayName>abcdefghijklmnopqrstuvwxyz</MPReg:PersonDisplayName>
<MPReg:Rectangle>0.451041666666667, 0.13287037037037, 0.110416666666667, 0.24537037037037</MPReg:Rectangle>
</rdf:li>
<rdf:li rdf:parseType='Resource'>
<MPReg:PersonDisplayName>abcdefghijklmnopqrstuvwxyz</MPReg:PersonDisplayName>
<MPReg:Rectangle>0.605208333333333, 0.138425925925926, 0.110416666666667, 0.24537037037037</MPReg:Rectangle>
</rdf:li>
</rdf:Bag>
</MPRI:Regions>
</MP:RegionInfo>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:dc='http://purl.org/dc/elements/1.1/'>
<dc:subject>
<rdf:Bag>
<rdf:li>æÆøØåÅéÉüÜäÄöÖïÏñÑ</rdf:li>
<rdf:li>abcdefghijklmnopqrstuvwxyz</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:exif='http://ns.adobe.com/exif/1.0/'>
<exif:ColorSpace>65535</exif:ColorSpace>
<exif:ComponentsConfiguration>
<rdf:Seq>
<rdf:li>1</rdf:li>
<rdf:li>2</rdf:li>
<rdf:li>3</rdf:li>
<rdf:li>0</rdf:li>
</rdf:Seq>
</exif:ComponentsConfiguration>
<exif:DateTimeOriginal>2024-01-31T00:02:07+01:00</exif:DateTimeOriginal>
<exif:ExifVersion>0232</exif:ExifVersion>
<exif:FlashpixVersion>0100</exif:FlashpixVersion>
<exif:GPSAltitude>102/1</exif:GPSAltitude>
<exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
<exif:GPSLatitude>57,46.8417528N</exif:GPSLatitude>
<exif:GPSLongitude>14,9.7753146E</exif:GPSLongitude>
<exif:GPSMapDatum>WGS-84</exif:GPSMapDatum>
<exif:GPSTimeStamp>1899-12-30T01:00:14Z</exif:GPSTimeStamp>
<exif:GPSVersionID>2.2.0.0</exif:GPSVersionID>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:mwg-rs='http://www.metadataworkinggroup.com/schemas/regions/'
xmlns:stArea='http://ns.adobe.com/xmp/sType/Area#'
xmlns:stDim='http://ns.adobe.com/xap/1.0/sType/Dimensions#'>
<mwg-rs:Regions rdf:parseType='Resource'>
<mwg-rs:AppliedToDimensions rdf:parseType='Resource'>
<stDim:h>1080</stDim:h>
<stDim:unit>pixel</stDim:unit>
<stDim:w>1920</stDim:w>
</mwg-rs:AppliedToDimensions>
<mwg-rs:RegionList>
<rdf:Bag>
<rdf:li rdf:parseType='Resource'>
<mwg-rs:Area rdf:parseType='Resource'>
<stArea:h>0.237962962962963</stArea:h>
<stArea:unit>normalized</stArea:unit>
<stArea:w>0.107291666666667</stArea:w>
<stArea:x>0.3484375</stArea:x>
<stArea:y>0.251851851851852</stArea:y>
</mwg-rs:Area>
<mwg-rs:Name>æÆøØåÅéÉüÜäÄöÖïÏñÑ</mwg-rs:Name>
<mwg-rs:Type>Face</mwg-rs:Type>
</rdf:li>
<rdf:li rdf:parseType='Resource'>
<mwg-rs:Area rdf:parseType='Resource'>
<stArea:h>0.24537037037037</stArea:h>
<stArea:unit>normalized</stArea:unit>
<stArea:w>0.110416666666667</stArea:w>
<stArea:x>0.50625</stArea:x>
<stArea:y>0.255555555555556</stArea:y>
</mwg-rs:Area>
<mwg-rs:Name>abcdefghijklmnopqrstuvwxyz</mwg-rs:Name>
<mwg-rs:Type>Face</mwg-rs:Type>
</rdf:li>
<rdf:li rdf:parseType='Resource'>
<mwg-rs:Area rdf:parseType='Resource'>
<stArea:h>0.24537037037037</stArea:h>
<stArea:unit>normalized</stArea:unit>
<stArea:w>0.110416666666667</stArea:w>
<stArea:x>0.660416666666667</stArea:x>
<stArea:y>0.261111111111111</stArea:y>
</mwg-rs:Area>
<mwg-rs:Name>abcdefghijklmnopqrstuvwxyz</mwg-rs:Name>
<mwg-rs:Type>Face</mwg-rs:Type>
</rdf:li>
</rdf:Bag>
</mwg-rs:RegionList>
</mwg-rs:Regions>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:pdf='http://ns.adobe.com/pdf/1.3/'>
<pdf:Keywords>æÆøØåÅéÉüÜäÄöÖïÏñÑ, abcdefghijklmnopqrstuvwxyz</pdf:Keywords>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
<photoshop:City>Jönköping</photoshop:City>
<photoshop:Country>Sverige</photoshop:Country>
<photoshop:State>Jönköping</photoshop:State>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
<tiff:BitsPerSample>
<rdf:Seq>
<rdf:li>8</rdf:li>
</rdf:Seq>
</tiff:BitsPerSample>
<tiff:ImageLength>1080</tiff:ImageLength>
<tiff:ImageWidth>1920</tiff:ImageWidth>
<tiff:ResolutionUnit>2</tiff:ResolutionUnit>
<tiff:XResolution>300/1</tiff:XResolution>
<tiff:YCbCrPositioning>1</tiff:YCbCrPositioning>
<tiff:YCbCrSubSampling>
<rdf:Seq>
<rdf:li>1</rdf:li>
<rdf:li>1</rdf:li>
</rdf:Seq>
</tiff:YCbCrSubSampling>
<tiff:YResolution>300/1</tiff:YResolution>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
<xmp:CreateDate>2024-01-31T00:02:07+01:00</xmp:CreateDate>
<xmp:CreatorTool>Tag That Photo</xmp:CreatorTool>
<xmp:MetadataDate>2024-01-30T23:02:06Z</xmp:MetadataDate>
<xmp:ModifyDate>2024-01-31T00:02:07+01:00</xmp:ModifyDate>
<xmp:Rating>-1</xmp:Rating>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>
49 changes: 49 additions & 0 deletions test/backend/assets/sidecar/Chars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"size": {
"width": 1920,
"height": 1080
},
"creationDate": 1706655727000,
"creationDateOffset": "+01:00",
"fileSize": 101948,
"positionData": {
"GPSData": {
"longitude": 14.162922,
"latitude": 57.780696
},
"country": "Sverige",
"state": "Jönköping",
"city": "Jönköping"
},
"keywords": [
],
"faces": [
{
"box": {
"width": 206,
"height": 257,
"left": 566,
"top": 144
},
"name": "æÆøØåÅéÉüÜäÄöÖïÏñÑ"
},
{
"name": "abcdefghijklmnopqrstuvwxyz",
"box": {
"width": 212,
"height": 265,
"left": 866,
"top": 144
}
},
{
"name": "abcdefghijklmnopqrstuvwxyz",
"box": {
"width": 212,
"height": 265,
"left": 1162,
"top": 150
}
}
]
}
Binary file added test/backend/assets/sidecar/Chars_exiftool.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading