feat: add progressive rendering option for static jpeg images (#1397)

This commit is contained in:
Samuel 2024-10-10 14:56:56 +01:00 committed by GitHub
parent 6f28feb947
commit 760653901e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 });
} }