1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

fixing date parsing bug

This commit is contained in:
Patrik J. Braun 2019-01-19 10:07:06 +01:00
parent 54781ee667
commit ca33bb1efb
4 changed files with 27 additions and 2 deletions

View File

@ -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 = <number>(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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -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
}
}

View File

@ -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);
});
});