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:
parent
54781ee667
commit
ca33bb1efb
@ -120,7 +120,7 @@ export class MetadataLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate) {
|
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) {
|
if (exif.tags.Orientation) {
|
||||||
@ -163,10 +163,11 @@ export class MetadataLoader {
|
|||||||
metadata.caption = iptcData.caption.replace(/\0/g, '').trim();
|
metadata.caption = iptcData.caption.replace(/\0/g, '').trim();
|
||||||
}
|
}
|
||||||
metadata.keywords = iptcData.keywords || [];
|
metadata.keywords = iptcData.keywords || [];
|
||||||
|
|
||||||
metadata.creationDate = <number>(iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate);
|
metadata.creationDate = <number>(iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate);
|
||||||
|
|
||||||
} catch (err) {
|
} 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;
|
metadata.creationDate = metadata.creationDate || 0;
|
||||||
|
BIN
test/backend/unit/assets/old_photo.jpg
Normal file
BIN
test/backend/unit/assets/old_photo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
17
test/backend/unit/assets/old_photo.json
Normal file
17
test/backend/unit/assets/old_photo.json
Normal 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
|
||||||
|
}
|
||||||
|
}
|
@ -24,4 +24,11 @@ describe('MetadataLoader', () => {
|
|||||||
expect(Utils.clone(data)).to.be.deep.equal(expected);
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user