From 15ca4ade9f9d8cd77979d2e0c3e57cbdea63656d Mon Sep 17 00:00:00 2001 From: Wentao Kuang Date: Thu, 5 Dec 2024 15:15:12 +1300 Subject: [PATCH] Disable fastShrinkOnLoad for the sacle lower than 0.125. --- packages/tiler-sharp/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/tiler-sharp/src/index.ts b/packages/tiler-sharp/src/index.ts index 6ae79bcf1..be062ea84 100644 --- a/packages/tiler-sharp/src/index.ts +++ b/packages/tiler-sharp/src/index.ts @@ -144,7 +144,11 @@ export class TileMakerSharp implements TileMaker { if (resize) { const resizeOptions = { fit: Sharp.fit.cover, kernel: resize.scaleX > 1 ? resizeKernel.in : resizeKernel.out }; - sharp.resize(resize.width, resize.height, resizeOptions); + if (resize.scale <= 0.1251) { + sharp.resize(resize.width, resize.height, { ...resizeOptions, fastShrinkOnLoad: false }); + } else { + sharp.resize(resize.width, resize.height, resizeOptions); + } } if (crop) sharp.extract({ top: crop.y, left: crop.x, width: crop.width, height: crop.height });