Zlib
From Just Solve the File Format Problem
(Difference between revisions)
(→Software) |
(Added sample files) |
||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{FormatInfo | {{FormatInfo | ||
+ | |name=zlib | ||
|formattype=electronic | |formattype=electronic | ||
|subcat=Compression | |subcat=Compression | ||
+ | |released=1995 | ||
}} | }} | ||
{{DISPLAYTITLE:zlib}} | {{DISPLAYTITLE:zlib}} | ||
− | '''zlib''' is a | + | '''zlib''' format is a container and extension of the [[DEFLATE]] compressed data format. It adds a lightweight container, a small amount of configurability, and error checking. |
− | + | zlib is also the name of a software library that supports the zlib format, and other formats related to DEFLATE. | |
− | + | There are many formats and protocols that use, or may use, zlib format. A notable example is [[PNG]]. | |
== See also == | == See also == | ||
* [[Adler-32]] | * [[Adler-32]] | ||
+ | * [[DEFLATE]] | ||
== Identification == | == Identification == | ||
− | The first | + | The first two bytes can help to identify a zlib datastream. The following tests are ordered starting with those that are most certain to be true. |
− | If the first two bytes are interpreted as a [[Endianness|big-endian]] integer, it is always a multiple of 31. | + | * If the first two bytes are interpreted as a [[Endianness|big-endian]] integer, it is always a multiple of 31. (Always true) |
+ | * The first byte has eight possible values: <code>0x08</code>, <code>0x18</code>, <code>0x28</code>, ..., <code>0x78</code>. (Always true, unless the zlib format has been extended to support compression methods other than Deflate.) | ||
+ | * Almost always, the <code>0x20</code> bit of the second byte is 0. (A value of 1 is legal in zlib v3.3+, but indicates use of a preset dictionary, so the zlib stream is not as portable.) | ||
+ | * Most often, the Deflate window size is 32K, and there is no preset dictionary. With these assumptions, the first byte is <code>0x78</code>, and the second is <code>0x01</code> (if using fastest compression), <code>0x5e</code> (fast), <code>0x9c</code> (default), or <code>0xda</code> (max), with <code>0x9c</code> and <code>0xda</code> being the most common. | ||
+ | |||
+ | == Specifications == | ||
+ | * ZLIB Specification v3.1 - ''No copy found. There are dead links to it in e.g. the [https://zlib.net/fossils/zlib-0.95.tar.gz zlib 0.95] README file.'' | ||
+ | * [https://web.archive.org/web/20030426211434/http://mirror.cs.wisc.edu/pub/mirrors/ghost/gzip_doc/zlib-3.2.doc ZLIB Specification v3.2] (from archive.org) | ||
+ | * RFC 1950: ZLIB Compressed Data Format Specification version 3.3 | ||
== Software == | == Software == | ||
− | * [ | + | * [https://zlib.net zlib data compression library] |
− | + | * [https://github.com/cloudflare/zlib CloudFlare fork of zlib] | |
+ | * [https://github.com/zlib-ng/zlib-ng zlib-ng] | ||
+ | * Puff - Lightweight decompression software included with [https://zlib.net/ zlib] (contrib/puff) | ||
* [https://github.com/richgel999/miniz miniz] | * [https://github.com/richgel999/miniz miniz] | ||
* [https://github.com/google/zopfli zopfli] - zlib compressor highly optimized for file size | * [https://github.com/google/zopfli zopfli] - zlib compressor highly optimized for file size | ||
* [http://aluigi.altervista.org/mytoolz.htm#offzip Offzip] | * [http://aluigi.altervista.org/mytoolz.htm#offzip Offzip] | ||
+ | * {{Deark}} | ||
− | == | + | See also [[DEFLATE#Software]]. |
− | * | + | |
+ | == Sample files == | ||
+ | * {{DexvertSamples|archive/zlib}} | ||
− | == | + | == Links == |
* [[Wikipedia:Zlib|Wikipedia article]] | * [[Wikipedia:Zlib|Wikipedia article]] |
Latest revision as of 15:06, 28 December 2023
zlib format is a container and extension of the DEFLATE compressed data format. It adds a lightweight container, a small amount of configurability, and error checking.
zlib is also the name of a software library that supports the zlib format, and other formats related to DEFLATE.
There are many formats and protocols that use, or may use, zlib format. A notable example is PNG.
Contents |
[edit] See also
[edit] Identification
The first two bytes can help to identify a zlib datastream. The following tests are ordered starting with those that are most certain to be true.
- If the first two bytes are interpreted as a big-endian integer, it is always a multiple of 31. (Always true)
- The first byte has eight possible values:
0x08
,0x18
,0x28
, ...,0x78
. (Always true, unless the zlib format has been extended to support compression methods other than Deflate.) - Almost always, the
0x20
bit of the second byte is 0. (A value of 1 is legal in zlib v3.3+, but indicates use of a preset dictionary, so the zlib stream is not as portable.) - Most often, the Deflate window size is 32K, and there is no preset dictionary. With these assumptions, the first byte is
0x78
, and the second is0x01
(if using fastest compression),0x5e
(fast),0x9c
(default), or0xda
(max), with0x9c
and0xda
being the most common.
[edit] Specifications
- ZLIB Specification v3.1 - No copy found. There are dead links to it in e.g. the zlib 0.95 README file.
- ZLIB Specification v3.2 (from archive.org)
- RFC 1950: ZLIB Compressed Data Format Specification version 3.3
[edit] Software
- zlib data compression library
- CloudFlare fork of zlib
- zlib-ng
- Puff - Lightweight decompression software included with zlib (contrib/puff)
- miniz
- zopfli - zlib compressor highly optimized for file size
- Offzip
- Deark
See also DEFLATE#Software.