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:
commit
e3604c2334
@ -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) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
}
|
||||
],
|
||||
"fileSize": 4381,
|
||||
"keywords": [],
|
||||
"orientation": 1,
|
||||
"size": {
|
||||
"height": 26,
|
||||
|
BIN
test/backend/assets/xmp/xmp_subject.jpg
Normal file
BIN
test/backend/assets/xmp/xmp_subject.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
22
test/backend/assets/xmp/xmp_subject.json
Normal file
22
test/backend/assets/xmp/xmp_subject.json
Normal 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
|
||||
}
|
||||
}
|
@ -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'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user