From 760653901e52b70767bf9c724f6fb54dd0fd859a Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 10 Oct 2024 14:56:56 +0100 Subject: [PATCH] feat: add progressive rendering option for static jpeg images (#1397) --- docs/config.rst | 3 ++- src/serve_rendered.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 9d36a9454..d556dfa39 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -94,7 +94,8 @@ Use ``false`` to disable the front page altogether (404). ----------------- You can use this to specify options for the generation of images in the supported file formats. -For JPEG and WebP, the only supported option is ``quality`` [0-100]. +For WebP, the only supported option is ``quality`` [0-100]. +For JPEG, the only supported options are ``quality`` [0-100] and ``progressive`` [true, false]. For PNG, the full set of options `exposed by the sharp library `_ is available, except ``force`` and ``colours`` (use ``colors``). If not set, their values are the defaults from ``sharp``. For example:: diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 6017a9be4..3e5c94eaa 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -527,7 +527,10 @@ const respondImage = ( dither: formatOptions.dither, }); } else if (format === 'jpeg') { - image.jpeg({ quality: formatOptions.quality || formatQuality || 80 }); + image.jpeg({ + quality: formatOptions.quality || formatQuality || 80, + progressive: formatOptions.progressive, + }); } else if (format === 'webp') { image.webp({ quality: formatOptions.quality || formatQuality || 90 }); }