filter · Image filters
Convert GIF to PNG (convert_gif_to_png)
- Category:
- Image
- CoreFilters:
- Yes
- OptimizeForBandwidth:
- Yes
- Risk:
- Generally safe
convert_gif_to_png converts non-animated GIF images to PNG, which uses better compression.
How it works
convert_gif_to_png re-encodes a non-animated GIF as PNG. Without this filter, and without one of the animated-format conversions or the low-resolution preview path that need the same decode, a GIF that is not resized passes through the module untouched: no other filter re-encodes it. A resized GIF is decoded and resized as a PNG, so with this filter on it ships as PNG (or, if photographic and the lossy conversions apply, as JPEG or WebP); it never goes back out as a GIF. The conversion is lossless in intent (a GIF’s at-most-256-color palette maps into PNG), and the result is kept only when it is smaller than the original GIF under ImageLimitOptimizedPercent. One non-obvious effect: the filter also unlocks lossy treatment of photographic GIFs, because the lossy decision path accepts a GIF only when it may first be treated as a PNG-style source. With the filter off, a photographic GIF is never turned into a JPEG or lossy WebP; it can still leave as lossless WebP or AVIF when those conversions are enabled, and otherwise stays a GIF. The filter runs in CoreFilters through rewrite_images.
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_imagesandrewrite_images. - Risk rating on these docs: Generally safe.
Risks
The
Image filters
page lists no specific risks for this filter.
If a page misbehaves with it, DisableFilters convert_gif_to_png turns it off for
the scope you set it in.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters convert_gif_to_pngnginx
pagespeed EnableFilters convert_gif_to_png;IIS (pagespeed.config)
pagespeed EnableFilters convert_gif_to_pngIt is on by default under CoreFilters; to turn it off:
ModPagespeedDisableFilters convert_gif_to_png # Apache
pagespeed DisableFilters convert_gif_to_png; # nginx
pagespeed DisableFilters convert_gif_to_png # IIS| Parameter | Default | Description |
|---|---|---|
ProgressiveJpegMinBytes | 10240 | Minimum JPEG size before converting to progressive |
WebpRecompressionQuality | 80 | Quality for lossy WebP conversion |
WebpAnimatedRecompressionQuality | 70 | Quality for animated WebP conversion |
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Frequently asked questions
- What does the convert_gif_to_png filter do?
convert_gif_to_pngconverts non-animated GIF images to PNG, which uses better compression.- Is convert_gif_to_png enabled by default?
- Yes.
convert_gif_to_pngis in CoreFilters, the default RewriteLevel, so it runs unless you turn it off withDisableFilters. It is also part of the OptimizeForBandwidth level. - How do I turn off convert_gif_to_png?
- Add
ModPagespeedDisableFilters convert_gif_to_pngon Apache orpagespeed DisableFilters convert_gif_to_png;on nginx. On IIS, addpagespeed DisableFilters convert_gif_to_pngto pagespeed.config.
Related filters
- convert_jpeg_to_progressive — Progressive JPEG
- convert_jpeg_to_webp — Convert JPEG to WebP
- convert_png_to_jpeg — Convert PNG to JPEG
- convert_to_webp_animated — Animated WebP
- convert_to_webp_lossless — Lossless WebP
- convert_jpeg_to_avif — Convert JPEG to AVIF
- convert_to_avif_animated — Animated AVIF
- convert_to_avif_lossless — Lossless AVIF
This page is drawn from the convert_gif_to_png entry on Image filters. Every filter in one table: PageSpeed filters.