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

adding thumbnail info to persons

This commit is contained in:
Patrik J. Braun 2019-03-03 12:11:16 +01:00
parent 0d3b8823e4
commit 6533f4b793
2 changed files with 11 additions and 12 deletions

View File

@ -141,6 +141,8 @@ export class ThumbnailGeneratorMWs {
x: Math.round(photo.metadata.faces[0].box.width * (Config.Server.thumbnail.personFaceMargin)),
y: Math.round(photo.metadata.faces[0].box.height * (Config.Server.thumbnail.personFaceMargin))
};
// run on other thread
const input = <RendererInput>{
type: ThumbnailSourceType.Image,
@ -149,13 +151,15 @@ export class ThumbnailGeneratorMWs {
thPath: thPath,
makeSquare: false,
cut: {
x: Math.round(Math.max(0, photo.metadata.faces[0].box.x - margin.x / 2)),
y: Math.round(Math.max(0, photo.metadata.faces[0].box.y - margin.y / 2)),
left: Math.round(Math.max(0, photo.metadata.faces[0].box.x - margin.x / 2)),
top: Math.round(Math.max(0, photo.metadata.faces[0].box.y - margin.y / 2)),
width: photo.metadata.faces[0].box.width + margin.x,
height: photo.metadata.faces[0].box.height + margin.y
},
qualityPriority: Config.Server.thumbnail.qualityPriority
};
input.cut.width = Math.min(input.cut.width, photo.metadata.size.width - input.cut.left);
input.cut.height = Math.min(input.cut.height, photo.metadata.size.height - input.cut.top);
try {
await ThumbnailGeneratorMWs.taskQue.execute(input);
return next();

View File

@ -48,8 +48,8 @@ export interface RendererInput {
thPath: string;
qualityPriority: boolean;
cut?: {
x: number,
y: number,
left: number,
top: number,
width: number,
height: number
};
@ -149,8 +149,8 @@ export class ImageRendererFactory {
if (input.cut) {
image.crop(
input.cut.x,
input.cut.y,
input.cut.left,
input.cut.top,
input.cut.width,
input.cut.height
);
@ -199,12 +199,7 @@ export class ImageRendererFactory {
const kernel = input.qualityPriority === true ? sharp.kernel.lanczos3 : sharp.kernel.nearest;
if (input.cut) {
image.extract({
top: input.cut.y,
left: input.cut.x,
width: input.cut.width,
height: input.cut.height
});
image.extract(input.cut);
}
if (input.makeSquare === false) {
const newWidth = Math.round(Math.sqrt((input.size * input.size) / ratio));