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

fixing sharp error

This commit is contained in:
Patrik J. Braun 2018-01-15 21:12:51 -05:00
parent 63b300c40a
commit 9e967c69cd

View File

@ -101,19 +101,16 @@ export class RendererFactory {
*/
const ratio = metadata.height / metadata.width;
const kernel = input.qualityPriority == true ? sharp.kernel.lanczos3 : sharp.kernel.nearest;
const interpolator = input.qualityPriority == true ? sharp.interpolator.bicubic : sharp.interpolator.nearest;
if (input.makeSquare == false) {
const newWidth = Math.round(Math.sqrt((input.size * input.size) / ratio));
image.resize(newWidth, null, {
kernel: kernel,
interpolator: interpolator
kernel: kernel
});
} else {
image
.resize(input.size, input.size, {
kernel: kernel,
interpolator: interpolator
kernel: kernel
})
.crop(sharp.strategy.center);
}