mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-23 01:27:14 +02:00
Added a test for offset-fix and found another bug - also fixed
This commit is contained in:
parent
f8021348db
commit
7411750ffd
@ -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;
|
||||
|
BIN
test/backend/assets/wild-2-small.jpg
Normal file
BIN
test/backend/assets/wild-2-small.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
test/backend/assets/wild-2-small.jpg_original
Normal file
BIN
test/backend/assets/wild-2-small.jpg_original
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
20
test/backend/assets/wild-2-small.json
Normal file
20
test/backend/assets/wild-2-small.json
Normal 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"
|
||||
}
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user