Skip to content

Commit

Permalink
feat: add progressive rendering option for static jpeg images
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-git committed Sep 30, 2024
1 parent 6f28feb commit 26fed9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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::
Expand Down
5 changes: 4 additions & 1 deletion src/serve_rendered.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand Down

0 comments on commit 26fed9b

Please sign in to comment.