fix(refboard): reuse full image for LOD tiers when source is smaller

Don't re-encode small images to WebP unnecessarily — just return the
original buffer for tiers where the source is already smaller than target.
This commit is contained in:
Hiren Kangad
2026-03-09 22:57:10 +05:30
parent e43f8eff07
commit 02a04d6e24
+2 -4
View File
@@ -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)