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

Added a test for offset-fix and found another bug - also fixed

This commit is contained in:
gras 2024-04-03 22:50:49 +02:00
parent f8021348db
commit 7411750ffd
5 changed files with 30 additions and 5 deletions

View File

@ -144,11 +144,11 @@ export class Utils {
//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) {
const offsetRegex = /[+-]\d{2}:\d{2}$/;
var match = timestamp.match(offsetRegex);
if (match) {
return match[0];
} else if (timestamp.indexOf("Z") > 0) {
return '+00:00';
}
return undefined;

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -0,0 +1,20 @@
{
"size": {
"width": 306,
"height": 204
},
"creationDate": 1435943085000,
"fileSize": 62306,
"positionData": {
"country": "United States",
"state": "Arizona",
"city": "Williams"
},
"keywords": ["Akela the wolf", "Balu the bear", "Bearizona", "Hugin the raven", "USA", "USA Road trip"],
"cameraData": {
"make": "Canon",
"model": "Canon EOS 600D",
"lens": "EF-S15-85mm f/3.5-5.6 IS USM"
},
"creationDateOffset": "-07:00"
}

View File

@ -179,6 +179,11 @@ describe('MetadataLoader', () => {
const expected = require(path.join(__dirname, '/../../../assets/wild-1-small.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should load wild-2-small image with xmp-CreateDate from 2015 and negative offset', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/wild-2-small.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/wild-2-small.json'));
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
describe('should load jpg with edge case exif data', () => {
const root = path.join(__dirname, '/../../../assets/edge_case_exif_data');