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 ratio = metadata.height / metadata.width;
const kernel = input.qualityPriority == true ? sharp.kernel.lanczos3 : sharp.kernel.nearest; 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) { 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));
image.resize(newWidth, null, { image.resize(newWidth, null, {
kernel: kernel, kernel: kernel
interpolator: interpolator
}); });
} else { } else {
image image
.resize(input.size, input.size, { .resize(input.size, input.size, {
kernel: kernel, kernel: kernel
interpolator: interpolator
}) })
.crop(sharp.strategy.center); .crop(sharp.strategy.center);
} }