Skip to main content

filter · Image filters

Recompress WebP (recompress_webp)

Category:
Image
CoreFilters:
Yes
OptimizeForBandwidth:
Yes
Risk:
Generally safe

recompress_webp re-encodes WebP images the page already serves, at WebpRecompressionQuality (default 80). It does not create WebP; converting JPEG or PNG sources to WebP is the conversion filters’ job. Animated WebP is never recompressed, and there is no fallback conversion of WebP to JPEG for browsers without WebP support: such sources are left alone rather than transcoded.

How it works

The recompression filters reduce image file size by re-encoding images at an optimal quality level. They preserve visual quality while removing encoding inefficiencies, and each one handles exactly the format its name says, so a format you do not want re-encoded can be turned off by name without touching the others.

How each format is recompressed

recompress_webp keeps a re-encode only when it is smaller under ImageLimitOptimizedPercent, and a losing result is remembered. A small-screen client gets a lower quality still: WebpRecompressionQualityForSmallScreens (default 70) applies to the requests the module classifies as small-screen. The filter is a CoreFilter through rewrite_images and part of OptimizeForBandwidth.

recompress_images is a convenience filter that enables recompress_jpeg, recompress_png, and recompress_webp together with convert_gif_to_png, convert_jpeg_to_progressive, convert_jpeg_to_webp, convert_png_to_jpeg, jpeg_subsampling, strip_image_color_profile, and strip_image_meta_data.

When to use it

  • In CoreFilters, the default RewriteLevel: it runs unless you disable it.
  • Part of OptimizeForBandwidth, the level that optimizes resources without changing their URLs.
  • Also switched on by recompress_images and rewrite_images.
  • Risk rating on these docs: Generally safe.

Risks

Recompression is lossy. Setting quality too low produces visible artifacts. The default values are conservative and safe for most content. Photographic content can tolerate lower quality than screenshots or text-heavy images.

Configuration

Enable it in the module configuration, at server, virtual-host or location scope:

Apache

ModPagespeedEnableFilters recompress_webp

nginx

pagespeed EnableFilters recompress_webp;

IIS (pagespeed.config)

pagespeed EnableFilters recompress_webp

It is on by default under CoreFilters; to turn it off:

ModPagespeedDisableFilters recompress_webp   # Apache
pagespeed DisableFilters recompress_webp;   # nginx
pagespeed DisableFilters recompress_webp   # IIS
ParameterDefaultDescription
ImageRecompressionQuality85General quality level for recompressed images (-1 to 100; -1 uses source quality)
JpegRecompressionQuality-1JPEG-specific quality; -1 uses ImageRecompressionQuality
WebpRecompressionQuality80WebP quality level

On the worker

The worker runs its own pipeline, configured by flags. Its equivalent of this filter is the image pipeline transform. Always-on baseline under pagespeed on;; there is no per-transform off switch.

Scoping, ForbidFilters and the thresholds filters read: Choosing filters .

Frequently asked questions

What does the recompress_webp filter do?
recompress_webp re-encodes WebP images the page already serves, at WebpRecompressionQuality (default 80). It does not create WebP; converting JPEG or PNG sources to WebP is the conversion filters' job. Animated WebP is never recompressed, and there is no fallback conversion of WebP to JPEG for browsers without WebP support: such sources are left alone rather than transcoded.
Is recompress_webp enabled by default?
Yes. recompress_webp is in CoreFilters, the default RewriteLevel, so it runs unless you turn it off with DisableFilters. It is also part of the OptimizeForBandwidth level.
How do I turn off recompress_webp?
Add ModPagespeedDisableFilters recompress_webp on Apache or pagespeed DisableFilters recompress_webp; on nginx. On IIS, add pagespeed DisableFilters recompress_webp to pagespeed.config.

This page is drawn from the recompress_webp entry on Image filters. Every filter in one table: PageSpeed filters.

Search