Home > Linux > Zopfli Library Improves Zlib Compression by 3 to 8%

Zopfli Library Improves Zlib Compression by 3 to 8%

Google developers have released a new compression library called Zopfli. This library, written in C, is compatible with zlib, yet provide a better compression, more exactly 3 to 8% according to Google.

This library can be used on servers for better compression in order to save bandwidth, as well as delivering web pages faster. Since it’s fully compatible with zlib, the web browsers do not need to be changed. The only drawback is that it’s several magnitude slower than zlib, so it’s better used for static content that is compressed once, and sent over the Internet many times, and it may not be a good choice for dynamic content.

The source code is available at https://code.google.com/p/zopfli/, so let’s try it.

Get the code and build zopfli:

git clone https://code.google.com/p/zopfli/
cd zopfli
make

Different levels of compression are available:

./zopfli -h
Usage: zopfli [OPTION]... FILE
  -h    gives this help
  -c    write the result on standard output, instead of disk filename + '.gz'
  -v    verbose mode
  --gzip  output to gzip format (default)
  --deflate  output to deflate format instead of gzip
  --zlib  output to zlib format instead of gzip
  --i5  less compression, but faster
  --i10  less compression, but faster
  --i15  default compression, 15 iterations
  --i25  more compression, but slower
  --i50  more compression, but slower
  --i100  more compression, but slower
  --i250  more compression, but slower
  --i500  more compression, but slower
  --i1000  more compression, but slower

For testing purpose, I’ve just saved this blog as one html file (test.html – 67275 bytes) with different options to see the compression improvements and time it takes with zopfli.

Command line used for the test:

time ./zopfli --i15 test.html &&  ls-l test.html.gz

Here are the results (The first line is the compression with gzip (gzip -9 test.html):

Option File Size (Bytes) Improvement Time (s)
Gzip -9 15337 0.011
i5 14942 2.58% 0.186
i10 14942 2.58% 0.287
i15 14942 2.58% 0.394
i25 14939 2.60% 0.619
i50 14937 2.61% 1.131
i100 14937 2.61% 2.199
i250 14934 2.63% 5.335
i500 14934 2.63% 11.679
i1000 14934 2.63% 21.412

If you run zopfli without options it will output to gzip format with 15 iterations (i15). With this particular html file, zopfli can achieve around 2.6% better compression than gzip -9, but it’s way slower on my machine, with the fastest option being about 17x slower.

Running gzip -d test.html.gz on a file compressed with zopfli, just works as advertised.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Categories: Linux Tags: Linux, compression, gzip, open source, zlib, zopfli
  1. notzed
    March 2nd, 2013 at 05:21 | #1

    But how does it compare to other free compression bzip2, or 7zip-lzma?

  2. notzed
    March 2nd, 2013 at 06:04 | #2

    They’d be better off just supporting a more modern compressor in the client, they could easily get mozilla on-board which would stick up the majority of the web.

    The improvement just from the major segment of the browser market would probably more in total than just this modest improvement.

    e.g. lzma gets nearly 9% on the front page, at about 450ms (unusually high sys time though)

  3. March 2nd, 2013 at 13:56 | #3

    I did not see it yesterday, but Google published their benchmark results: https://zopfli.googlecode.com/files/Data_compression_using_Zopfli.pdf

  1. March 5th, 2013 at 23:59 | #1