feat: add progressive rendering option for static jpeg images

This commit is contained in:
Samuel Leihkamm 2024-09-26 14:41:53 +02:00
parent 6f28feb947
commit 76611738f0
2 changed files with 6 additions and 2 deletions

View file

@ -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. 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 <https://sharp.pixelplumbing.com/api-output#png>`_ is available, except ``force`` and ``colours`` (use ``colors``). If not set, their values are the defaults from ``sharp``. For PNG, the full set of options `exposed by the sharp library <https://sharp.pixelplumbing.com/api-output#png>`_ is available, except ``force`` and ``colours`` (use ``colors``). If not set, their values are the defaults from ``sharp``.
For example:: For example::

View file

@ -527,7 +527,10 @@ const respondImage = (
dither: formatOptions.dither, dither: formatOptions.dither,
}); });
} else if (format === 'jpeg') { } 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') { } else if (format === 'webp') {
image.webp({ quality: formatOptions.quality || formatQuality || 90 }); image.webp({ quality: formatOptions.quality || formatQuality || 90 });
} }