diff --git a/backend/model/threading/MetadataLoader.ts b/backend/model/threading/MetadataLoader.ts index dea09323..14a5eb9e 100644 --- a/backend/model/threading/MetadataLoader.ts +++ b/backend/model/threading/MetadataLoader.ts @@ -120,7 +120,7 @@ export class MetadataLoader { } if (exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate) { - metadata.creationDate = exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate; + metadata.creationDate = (exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate) * 1000; } if (exif.tags.Orientation) { @@ -163,10 +163,11 @@ export class MetadataLoader { metadata.caption = iptcData.caption.replace(/\0/g, '').trim(); } metadata.keywords = iptcData.keywords || []; + metadata.creationDate = (iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate); } catch (err) { - // Logger.debug(LOG_TAG, 'Error parsing iptc data', fullPath, err); + // Logger.debug(LOG_TAG, 'Error parsing iptc data', fullPath, err); } metadata.creationDate = metadata.creationDate || 0; diff --git a/test/backend/unit/assets/old_photo.jpg b/test/backend/unit/assets/old_photo.jpg new file mode 100644 index 00000000..0f257df7 Binary files /dev/null and b/test/backend/unit/assets/old_photo.jpg differ diff --git a/test/backend/unit/assets/old_photo.json b/test/backend/unit/assets/old_photo.json new file mode 100644 index 00000000..249c328e --- /dev/null +++ b/test/backend/unit/assets/old_photo.json @@ -0,0 +1,17 @@ +{ + "cameraData": { + "ISO": 200, + "exposure": 0.008, + "fStop": 2.8, + "focalLength": 9.4, + "make": "FUJIFILM", + "model": "FinePix F601 ZOOM" + }, + "creationDate": 1126455782000, + "fileSize": 2582, + "orientation": 1, + "size": { + "height": 5, + "width": 7 + } +} diff --git a/test/backend/unit/model/threading/MetaDataLoader.spec.ts b/test/backend/unit/model/threading/MetaDataLoader.spec.ts index 19ad2096..468fa9ff 100644 --- a/test/backend/unit/model/threading/MetaDataLoader.spec.ts +++ b/test/backend/unit/model/threading/MetaDataLoader.spec.ts @@ -24,4 +24,11 @@ describe('MetadataLoader', () => { expect(Utils.clone(data)).to.be.deep.equal(expected); }); + + it('should load jpg 2', async () => { + const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../assets/old_photo.jpg')); + const expected = require(path.join(__dirname, '/../../assets/old_photo.json')); + expect(Utils.clone(data)).to.be.deep.equal(expected); + }); + });