From 02a04d6e24c0d797c122852b6d846a6392225b5e Mon Sep 17 00:00:00 2001 From: Hiren Kangad Date: Mon, 9 Mar 2026 22:57:10 +0530 Subject: [PATCH] fix(refboard): reuse full image for LOD tiers when source is smaller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't re-encode small images to WebP unnecessarily — just return the original buffer for tiers where the source is already smaller than target. --- backend/services/lod-generator.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/services/lod-generator.js b/backend/services/lod-generator.js index 59db7c1..76b07bd 100644 --- a/backend/services/lod-generator.js +++ b/backend/services/lod-generator.js @@ -40,10 +40,8 @@ async function generateLOD(buffer, originalExt) { const { maxWidth, quality } = LOD_TIERS[tierKey]; if (origWidth <= maxWidth) { - // Image is smaller than tier width — convert to WebP but don't upscale - const result = sharp(buffer).webp({ quality }); - const outBuf = await result.toBuffer(); - return { buffer: outBuf, ext: '.webp', width: origWidth, height: origHeight }; + // Image is smaller than tier width — reuse full image, no point re-encoding + return full; } // Resize down (width-based, preserve aspect ratio)