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

Merge pull request #270 from kagahd/issue267

#267 support XMP tag 'subject'
This commit is contained in:
Patrik J. Braun 2021-04-26 22:03:42 +02:00 committed by GitHub
commit e3604c2334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 1 deletions

View File

@ -216,7 +216,17 @@ export class MetadataLoader {
if (exif.Rating) {
metadata.rating = (parseInt(exif.Rating.value, 10) as any);
}
if(exif.subject && exif.subject.value && exif.subject.value.length > 0){
if(metadata.keywords == undefined) {
metadata.keywords = [];
}
for(let i=0; i < exif.subject.value.length; i++){
const kw = exif.subject.value[i].description;
if(metadata.keywords.indexOf(kw) == -1) {
metadata.keywords.push(kw);
}
}
}
if (exif.Orientation) {
metadata.orientation = (parseInt(exif.Orientation.value as any, 10) as any);
if (OrientationTypes.BOTTOM_LEFT < metadata.orientation) {

View File

@ -20,6 +20,7 @@
}
],
"fileSize": 4381,
"keywords": [],
"orientation": 1,
"size": {
"height": 26,

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -0,0 +1,22 @@
{
"cameraData": {
"ISO": 50,
"exposure": 0.007751937984496124,
"fStop": 2.4,
"focalLength": 4.32,
"make": "samsung",
"model": "SM-G975F"
},
"creationDate": 1614703656000,
"fileSize": 4709,
"orientation": 1,
"keywords": [
"Max",
"Spaß",
"Yanik"
],
"size": {
"height": 5,
"width": 10
}
}

View File

@ -26,6 +26,11 @@ describe('MetadataLoader', () => {
expect(Utils.clone(data)).to.be.deep.equal(expected);
});
it('should load xmp section dc:subject into keywords', async () => {
const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/xmp/xmp_subject.jpg'));
const expected = require(path.join(__dirname, '/../../../assets/xmp/xmp_subject.json'));
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'));