Skip to content
All writing Part 01 of 03 · Image Format Benchmark: WebP Wins
Engineering · 6 min read

GIF to Animated WebP: The Biggest Savings

Converting 25 production GIFs to animated WebP cut the median file size by 51%. All 25 kept their frame count and timing. This post covers the numbers, the animation integrity check, and a libvips pitfall.

What we asked

Of the three source formats (JPEG, GIF, PNG), which one wastes the most bandwidth? GIF. A single GIF today spends roughly twice the bytes it needs to. We converted all 25 production GIFs to animated WebP and animated AVIF, then compared size and quality per file.

How we measured

Each GIF went through the same conversion pipeline the image conversion service uses. The Go image library (govips v2.15.0) handled the WebP path. The AVIF path required a separate tool (more on that in the pitfall section below). We recorded file size, SSIM (visual similarity, 0 to 1), and encode time for every conversion.

p25 / p50 / p75 are quartiles. One quarter of the images save at least the p25 value. Half save at least the p50 value.

Size reduction

Conversionp25p50p75SSIM p50SSIM min
GIF to WebP (q80)41.1%51.0%61.6%0.9800.949
GIF to AVIF (q80)46.6%54.0%63.3%0.9940.979

Both formats cut GIF size by half at the median. AVIF compresses 3 percentage points more, but that gap is small compared to the shared gain over the original GIF.

By original file size

The savings hold across all size groups, not only in one range:

Size groupCountOriginal size rangeWebP savings p50AVIF savings p50
Small719.5 KB to 36.9 KB40.6%49.4%
Mid1153.2 KB to 164.1 KB61.6%63.3%
Large7183.6 KB to 290.9 KB45.6%50.7%

Mid-range GIFs save the most. Small GIFs save less in percentage but are already light.

Animation integrity

Converting a GIF to another format can break the animation. Frames can merge, timing can drift, and the loop can stop. We checked all 25 conversions:

  • Frame count: 25 out of 25 pass. The converted file keeps the same frame count as the source GIF.
  • Frame delays: pass. The animation timing matches the original.
  • Visual quality: all SSIM values are 0.949 or higher. The eye cannot tell the difference.

The animated AVIF pitfall

This section tells the story of a bug we found and fixed during the benchmark. It matters because it shows why animated WebP is safer to ship today.

Attempt 1: govips ExportAvif. The Go image library wrote a multi-page HEIF container (the file reported multiple pages). But it did not transfer the GIF frame-delay timing into the HEIF sequence. The browser showed only the first frame. The animation looked static.

Root cause: libvips ExportAvif (the heifsave operation) writes each frame as a HEIF page, but does not write the per-frame delay metadata. This is a libvips limitation, not an AVIF format limitation.

Attempt 2: ffmpeg without -fps_mode passthrough. We switched to ffmpeg. It produced 1,000 interpolated frames at 100 fps instead of the original 4 frames. The file was 2x larger than the source GIF. The first frame held for 2 seconds, then the animation played too fast. It looked broken.

Attempt 3: ffmpeg with -fps_mode passthrough. This flag tells ffmpeg to keep the original frame count and per-frame timing. It worked. All 25 GIFs converted with correct frame count, correct delays, and correct SSIM.

Animated AVIF: Three Attempts Source GIF (4 frames) Converter Result 1. govips ExportAvif No frame-delay metadata Static (1 visible frame) 2. ffmpeg (no passthrough) Interpolates frames 1,000 frames, 2x size Broken timing 3. ffmpeg + -fps_mode passthrough Preserves original timing 4 frames, correct delays 54% smaller than GIF Animated WebP (govips) works on the first attempt. No special path needed. This is one more reason to ship WebP first.
Animated AVIF took three attempts. Animated WebP worked on the first try with govips.

The takeaway: animated WebP works natively in govips (the Go wrapper for libvips). Animated AVIF needs a separate ffmpeg path with a specific flag. For a production image conversion service, that extra path is extra complexity and extra risk. This is one more reason to ship WebP first.

Encode time

Encode time (the CPU cost to convert one image) is a one-time cost at upload. Users never wait on it. But it affects how fast the conversion service processes a batch.

Conversionp25p50p75
GIF to WebP8 ms45 ms61 ms
GIF to AVIF (ffmpeg)366 ms1,793 ms2,333 ms
JPEG to WebP5 ms14 ms23 ms
JPEG to AVIF171 ms340 ms521 ms
PNG to WebP7 ms9 ms17 ms
PNG to AVIF205 ms268 ms577 ms

GIF to WebP takes 45 ms at the median. GIF to AVIF takes 1,793 ms. That is 40x slower. The AVIF encode time for GIF is high because it runs through the ffmpeg path (the pitfall fix above). For JPEG and PNG the gap is smaller (24x to 30x), because those use the govips path for both formats.

The encode speed difference is not a reason to reject AVIF outright. But it does mean the conversion service needs more capacity for AVIF. For a first rollout, WebP is the lighter lift.

What this means for the serving experience

GIF is where the format change has the largest impact on user experience. The same animation, 51% less data, all frames and timing preserved. The conversion path (govips) handles animated WebP natively. No special tool, no flag, no second attempt.

For the deeper comparison of WebP vs AVIF across all three source formats, see Part 02: WebP vs AVIF.


References:

Related: Back to the Image Format Benchmark overview. For how GIF animation works as a page-strip in libvips, see libvips stores animation as a page-strip from the image processing series.

Tags #image-optimization #web-performance
// connect

Be brave | Be wise | Be grateful

21 BreakinCode

// elsewhere
LinkedInMedium (lang: en)Life RecordYoutube
wh:~$William Hung· © 2026 Taipei · GMT+8 · Available for collaboration