• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

go/H27-Nov-2019-252147

src/H27-Nov-2019-16,31210,358

CONTRIBUTING.mdH A D27-Nov-20191.4 KiB2521

CONTRIBUTORSH A D27-Nov-2019137 109

COPYINGH A D27-Nov-201911.1 KiB202169

MakefileH A D27-Nov-20192.3 KiB6644

READMEH A D27-Nov-20191.8 KiB4030

README.zopflipngH A D27-Nov-20192.9 KiB5544

README

1Zopfli Compression Algorithm is a compression library programmed in C to perform
2very good, but slow, deflate or zlib compression.
3
4The basic function to compress data is ZopfliCompress in zopfli.h. Use the
5ZopfliOptions object to set parameters that affect the speed and compression.
6Use the ZopfliInitOptions function to place the default values in the
7ZopfliOptions first.
8
9ZopfliCompress supports deflate, gzip and zlib output format with a parameter.
10To support only one individual format, you can instead use ZopfliDeflate in
11deflate.h, ZopfliZlibCompress in zlib_container.h or ZopfliGzipCompress in
12gzip_container.h.
13
14ZopfliDeflate creates a valid deflate stream in memory, see:
15http://www.ietf.org/rfc/rfc1951.txt
16ZopfliZlibCompress creates a valid zlib stream in memory, see:
17http://www.ietf.org/rfc/rfc1950.txt
18ZopfliGzipCompress creates a valid gzip stream in memory, see:
19http://www.ietf.org/rfc/rfc1952.txt
20
21This library can only compress, not decompress. Existing zlib or deflate
22libraries can decompress the data.
23
24zopfli_bin.c is separate from the library and contains an example program to
25create very well compressed gzip files. Currently the makefile builds this
26program with the library statically linked in.
27
28The source code of Zopfli is under src/zopfli. Build instructions:
29
30To build zopfli, compile all .c source files under src/zopfli to a single binary
31with C, and link to the standard C math library, e.g.:
32gcc src/zopfli/*.c -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -lm -o zopfli
33
34A makefile is provided as well, but only for linux. Use "make" to build the
35binary, "make libzopfli" to build it as a shared library. For other platforms,
36please use the build instructions above instead.
37
38Zopfli Compression Algorithm was created by Lode Vandevenne and Jyrki
39Alakuijala, based on an algorithm by Jyrki Alakuijala.
40

README.zopflipng

1ZopfliPNG is a command line program to optimize the Portable Network Graphics
2(PNG) images. This version has the following features:
3- uses Zopfli compression for the Deflate compression,
4- compares several strategies for choosing scanline filter codes,
5- chooses a suitable color type to losslessly encode the image,
6- removes all chunks that are unimportant for the typical web use (metadata,
7  text, etc...),
8- optionally alters the hidden colors of fully transparent pixels for more
9  compression, and,
10- optionally converts 16-bit color channels to 8-bit.
11
12This is an alpha-release for testing while improvements, particularly to add
13palette selection, are still being made. Feedback and bug reports are welcome.
14
15Important:
16
17This PNG optimizer removes ancillary chunks (pieces of metadata) from the
18PNG image that normally do not affect rendering. However in special
19circumstances you may wish to keep some. For example for a design using
20custom gamma correction, keeping it may be desired. Visually check in the
21target renderer after using ZopfliPNG. Use --keepchunks to keep chunks, e.g.
22--keepchunks=gAMA,pHYs to keep gamma and DPI information. This will increase
23file size. The following page contains a list of ancillary PNG chunks:
24http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html
25
26Build instructions:
27
28To build ZopfliPNG, compile all .c, .cc and .cpp files from src/zopfli,
29src/zopflipng and src/zopflipng/lodepng, except src/zopfli/zopfli_bin.c, to a
30single binary with C++, e.g.:
31g++ src/zopfli/{blocksplitter,cache,deflate,gzip_container,hash,katajainen,lz77,squeeze,tree,util,zlib_container,zopfli_lib}.c src/zopflipng/*.cc src/zopflipng/lodepng/*.cpp -O2 -W -Wall -Wextra -Wno-unused-function -ansi -pedantic -o zopflipng
32
33A makefile is provided as well, but only for linux: use "make zopflipng" with
34the Zopfli makefile. For other platforms, please use the build instructions
35above instead.
36
37The main compression algorithm in ZopfliPNG is ported from WebP lossless, but
38naturally cannot give as much compression gain for PNGs as it does for a more
39modern compression codec like WebP
40https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification.
41
42Compared to libpng -- an often used PNG encoder implementation -- ZopfliPNG uses
432-3 orders of magnitude more CPU time for compression. Initial testing using a
44corpus of 1000 PNGs with translucency, randomly selected from the internet,
45gives a compression improvement of 12% compared to convert -q 95, but only 0.5%
46compared to pngout (from better of /f0 and /f5 runs).
47
48By releasing this software we hope to make images on the web load faster without
49a new image format, but the opportunities for optimization within PNG are
50limited. When targeting Android, Chrome, Opera, and Yandex browsers, or by using
51suitable plugins for other browsers, it is good to note that WebP lossless
52images are still 26 % smaller than images recompressed with ZopfliPNG.
53
542013-05-07, Lode Vandevenne and Jyrki Alakuijala
55