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

Support exiftool face region format

This commit is contained in:
Lorenz Bischof 2020-10-28 14:02:59 +01:00
parent c60bd99514
commit 17df914791
2 changed files with 38 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

View File

@ -210,12 +210,10 @@ export class MetadataLoader {
const faces: FaceRegion[] = [];
if (ret.Regions && ret.Regions.value.RegionList && ret.Regions.value.RegionList.value) {
for (let i = 0; i < ret.Regions.value.RegionList.value.length; i++) {
if (!ret.Regions.value.RegionList.value[i].value ||
!ret.Regions.value.RegionList.value[i].value['rdf:Description'] ||
!ret.Regions.value.RegionList.value[i].value['rdf:Description'].value ||
!ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area']) {
continue;
}
if (ret.Regions.value.RegionList.value[i].value &&
ret.Regions.value.RegionList.value[i].value['rdf:Description'] &&
ret.Regions.value.RegionList.value[i].value['rdf:Description'].value &&
ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area']) {
const region = ret.Regions.value.RegionList.value[i].value['rdf:Description'];
const regionBox = ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area'].attributes;
if (region.attributes['mwg-rs:Type'] !== 'Face' ||
@ -233,6 +231,24 @@ export class MetadataLoader {
box.left = Math.max(0, box.left - box.width / 2);
box.top = Math.max(0, box.top - box.height / 2);
faces.push({name: name, box: box});
} else if((ret.Regions.value.RegionList.value[i] as any).Area &&
(ret.Regions.value.RegionList.value[i] as any).Name &&
(ret.Regions.value.RegionList.value[i] as any).Type) {
const regionBox = (ret.Regions.value.RegionList.value[i] as any).Area.value;
const name = (ret.Regions.value.RegionList.value[i] as any).Name.value;
const type = (ret.Regions.value.RegionList.value[i] as any).Type.value;
if (type !== 'Face') continue;
const box = {
width: Math.round(parseFloat(regionBox.w.value) * metadata.size.width),
height: Math.round(parseFloat(regionBox.h.value) * metadata.size.height),
left: Math.round(parseFloat(regionBox.x.value) * metadata.size.width),
top: Math.round(parseFloat(regionBox.y.value) * metadata.size.height)
};
// convert center base box to corner based box
box.left = Math.max(0, box.left - box.width / 2);
box.top = Math.max(0, box.top - box.height / 2);
faces.push({name: name, box: box});
}
}
}
if (Config.Client.Faces.keywordsToPersons && faces.length > 0) {