Does GIF Compression Preserve Loop Count?

Our local test preserved all four loop-field states: absent, 0, 1 and 2. The same three-frame GIF shrank from 1,301 to 318 bytes without a loop extension, or from 1,320 to 337 bytes with one. Both tested settings kept the original loop field. These are local runs of SlimGIF’s deployed engine, not observed browser downloads; preserved metadata does not prove a browser’s exact repeat count.

Measured October 23, 2026. Own CC0 synthetic files, downloadable results and local decoding checks below.

What changed, and what stayed the same?

We generated four 80 × 48 GIFs with the same three opaque frames. Their stored delays are 120, 230 and 450 ms: one 800 ms cycle. Only the loop application extension differs. One input has no extension; the other three contain NETSCAPE2.0 with raw values 0, 1 and 2.

Local engine outputs; final column applies to both output settings
Input loop fieldInputLossless settingsDefault settingsOutput loop field
absent1,301 B318 B318 Babsent
01,320 B337 B337 B0
11,320 B337 B337 B1
21,320 B337 B337 B2

The absent-extension file is 19 bytes smaller than each corresponding extension-bearing file, before and after compression. That is a measured difference between these fixtures, not advice to remove a loop setting: changing that field changes the intended playback behavior.

Four loop fields remain absent, zero, one and two after both local compression settings
The two local compression settings produced the same byte size for each input. This four-color fixture does not test complex gradients or photographs.

What exactly did we run?

We used the same engine worker served by the GIF compressor, checked byte for byte against the public file before this test. For these opaque inputs, the current page selects optimization level 1. Our local lossless command was -O1 input.gif -o /out/output.gif. The local default-setting command added --colors 128 --lossy=30, with dimensions unchanged. Neither command sets a new loop count.

All generated outputs were smaller than their inputs. These are engine-run artifacts; we did not observe the page’s file selection, preview or download flow today. The engine SHA-256, commands, file hashes and measurements are in the evidence record.

How did we check the saved files?

We decoded the files locally with Pillow, checked the loop field, dimensions, frame count, frame delays and composited RGBA hashes, and separately parsed the GIF application-extension blocks. Each output kept the same application identifier and loop payload as its input. The absent input stayed absent; 0 was not substituted for a missing field.

FFmpeg independently decoded one stored cycle from every file with loop replay disabled. All 12 files contained three decoded frames with delays 120, 230 and 450 ms. For the lossless-setting outputs, the complete decoded RGBA sequence matched the corresponding input in both decoder checks. Those are local file checks, not a visual-quality score or a measurement of wall-clock browser playback.

Raw loop bytes and stored delays checked; browser repeat count remains untested
Separate the raw field, the decoded cycle and the player’s behavior when verifying an animation.

Does loop 0 mean play once?

No. Pillow’s GIF documentation describes 0 as infinite looping and distinguishes an omitted loop setting. A missing field and a zero field are different states. Our test verifies that compression preserved that distinction.

Does a stored value of 1 prove one visible playback?

Do not infer an exact playback count from this table. We report the stored number rather than relabeling it as a universal number of plays. WebKit issue 39857 documents a historical repeat-count interpretation discrepancy; it is marked fixed and is not evidence of a current browser bug. We did not compare current browsers’ finite-loop playback today.

Download and reproduce the experiment

Also available: FFmpeg results, command log, fixture and verification source, engine runner, and reproduction requirements. Scripts contain our local workspace paths, which need adjusting elsewhere. Our synthetic inputs and figures are CC0.

What this test does not establish

Four small opaque inputs are not a guarantee for every GIF, editing service or messaging platform. We did not measure subjective visual quality, browser scheduling, current cross-browser repeat counts or what a third-party platform does after upload. We did not run these files through competing tools. Default settings and lossless settings having equal sizes here does not make lossy compression universally lossless.

Try your own file in the GIF compressor and inspect the saved result. For frame storage and timing, see our duplicate-frame experiment; for a broader check, see keeping animation during compression.