From 75de7f2f181bb39a0897f14fe86d9742626d394d Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 20 May 2021 10:05:19 +0100 Subject: [PATCH] fix: add sharp optimisations --- src/lib/templates/imageFunction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/templates/imageFunction.js b/src/lib/templates/imageFunction.js index 66bad01a65..7be53b6251 100644 --- a/src/lib/templates/imageFunction.js +++ b/src/lib/templates/imageFunction.js @@ -94,9 +94,9 @@ const handler = async (event) => { // The format methods are just to set options: they don't // make it return that format. const { info, data: imageBuffer } = await sharp(bufferData) - .jpeg({ quality, force: ext === 'jpg' }) + .jpeg({ quality, mozjpeg: true, force: ext === 'jpg' }) + .png({ quality, palette: true, force: ext === 'png' }) .webp({ quality, force: ext === 'webp' }) - .png({ quality, force: ext === 'png' }) .avif({ quality, force: ext === 'avif' }) .resize(width) .toBuffer({ resolveWithObject: true })