From 26fed9bb10df489b34c4a411ae23a9d3cb8e5d3d Mon Sep 17 00:00:00 2001 From: Samuel Leihkamm Date: Thu, 26 Sep 2024 14:41:53 +0200 Subject: [PATCH] feat: add progressive rendering option for static jpeg images --- 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..df8067232 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`` boolean. 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 }); }