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:
parent
c60bd99514
commit
17df914791
BIN
demo/images/IMG_6253_exiftool.jpg
Normal file
BIN
demo/images/IMG_6253_exiftool.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 889 KiB |
@ -210,12 +210,10 @@ export class MetadataLoader {
|
|||||||
const faces: FaceRegion[] = [];
|
const faces: FaceRegion[] = [];
|
||||||
if (ret.Regions && ret.Regions.value.RegionList && ret.Regions.value.RegionList.value) {
|
if (ret.Regions && ret.Regions.value.RegionList && ret.Regions.value.RegionList.value) {
|
||||||
for (let i = 0; i < ret.Regions.value.RegionList.value.length; i++) {
|
for (let i = 0; i < ret.Regions.value.RegionList.value.length; i++) {
|
||||||
if (!ret.Regions.value.RegionList.value[i].value ||
|
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'] &&
|
||||||
!ret.Regions.value.RegionList.value[i].value['rdf:Description'].value ||
|
ret.Regions.value.RegionList.value[i].value['rdf:Description'].value &&
|
||||||
!ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area']) {
|
ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area']) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const region = ret.Regions.value.RegionList.value[i].value['rdf:Description'];
|
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;
|
const regionBox = ret.Regions.value.RegionList.value[i].value['rdf:Description'].value['mwg-rs:Area'].attributes;
|
||||||
if (region.attributes['mwg-rs:Type'] !== 'Face' ||
|
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.left = Math.max(0, box.left - box.width / 2);
|
||||||
box.top = Math.max(0, box.top - box.height / 2);
|
box.top = Math.max(0, box.top - box.height / 2);
|
||||||
faces.push({name: name, box: box});
|
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) {
|
if (Config.Client.Faces.keywordsToPersons && faces.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user