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:
parent
0d3b8823e4
commit
6533f4b793
@ -141,6 +141,8 @@ export class ThumbnailGeneratorMWs {
|
|||||||
x: Math.round(photo.metadata.faces[0].box.width * (Config.Server.thumbnail.personFaceMargin)),
|
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))
|
y: Math.round(photo.metadata.faces[0].box.height * (Config.Server.thumbnail.personFaceMargin))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// run on other thread
|
// run on other thread
|
||||||
const input = <RendererInput>{
|
const input = <RendererInput>{
|
||||||
type: ThumbnailSourceType.Image,
|
type: ThumbnailSourceType.Image,
|
||||||
@ -149,13 +151,15 @@ export class ThumbnailGeneratorMWs {
|
|||||||
thPath: thPath,
|
thPath: thPath,
|
||||||
makeSquare: false,
|
makeSquare: false,
|
||||||
cut: {
|
cut: {
|
||||||
x: Math.round(Math.max(0, photo.metadata.faces[0].box.x - margin.x / 2)),
|
left: 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)),
|
top: Math.round(Math.max(0, photo.metadata.faces[0].box.y - margin.y / 2)),
|
||||||
width: photo.metadata.faces[0].box.width + margin.x,
|
width: photo.metadata.faces[0].box.width + margin.x,
|
||||||
height: photo.metadata.faces[0].box.height + margin.y
|
height: photo.metadata.faces[0].box.height + margin.y
|
||||||
},
|
},
|
||||||
qualityPriority: Config.Server.thumbnail.qualityPriority
|
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 {
|
try {
|
||||||
await ThumbnailGeneratorMWs.taskQue.execute(input);
|
await ThumbnailGeneratorMWs.taskQue.execute(input);
|
||||||
return next();
|
return next();
|
||||||
|
@ -48,8 +48,8 @@ export interface RendererInput {
|
|||||||
thPath: string;
|
thPath: string;
|
||||||
qualityPriority: boolean;
|
qualityPriority: boolean;
|
||||||
cut?: {
|
cut?: {
|
||||||
x: number,
|
left: number,
|
||||||
y: number,
|
top: number,
|
||||||
width: number,
|
width: number,
|
||||||
height: number
|
height: number
|
||||||
};
|
};
|
||||||
@ -149,8 +149,8 @@ export class ImageRendererFactory {
|
|||||||
|
|
||||||
if (input.cut) {
|
if (input.cut) {
|
||||||
image.crop(
|
image.crop(
|
||||||
input.cut.x,
|
input.cut.left,
|
||||||
input.cut.y,
|
input.cut.top,
|
||||||
input.cut.width,
|
input.cut.width,
|
||||||
input.cut.height
|
input.cut.height
|
||||||
);
|
);
|
||||||
@ -199,12 +199,7 @@ export class ImageRendererFactory {
|
|||||||
const kernel = input.qualityPriority === true ? sharp.kernel.lanczos3 : sharp.kernel.nearest;
|
const kernel = input.qualityPriority === true ? sharp.kernel.lanczos3 : sharp.kernel.nearest;
|
||||||
|
|
||||||
if (input.cut) {
|
if (input.cut) {
|
||||||
image.extract({
|
image.extract(input.cut);
|
||||||
top: input.cut.y,
|
|
||||||
left: input.cut.x,
|
|
||||||
width: input.cut.width,
|
|
||||||
height: input.cut.height
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (input.makeSquare === false) {
|
if (input.makeSquare === false) {
|
||||||
const newWidth = Math.round(Math.sqrt((input.size * input.size) / ratio));
|
const newWidth = Math.round(Math.sqrt((input.size * input.size) / ratio));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user