Zlib
   HOME

TheInfoList



OR:

zlib ( or "
zeta Zeta (, ; uppercase Ζ, lowercase ζ; grc, ζῆτα, el, ζήτα, label= Demotic Greek, classical or ''zē̂ta''; ''zíta'') is the sixth letter of the Greek alphabet. In the system of Greek numerals, it has a value of 7. It was derived f ...
-lib", ) is a
software library In computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and sub ...
used for
data compression In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compressio ...
. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their
gzip gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and i ...
file compression program. zlib is also a crucial component of many software platforms, including
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
,
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
, and
iOS iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
. It has also been used in gaming consoles such as the PlayStation 4,
PlayStation 3 The PlayStation 3 (PS3) is a home video game console developed by Sony Computer Entertainment. The successor to the PlayStation 2, it is part of the PlayStation brand of consoles. It was first released on November 11, 2006, in Japan, November ...
,
Wii U The Wii U ( ) is a home video game console developed by Nintendo as the successor to the Wii. Released in late 2012, it is the first eighth-generation video game console and competed with Microsoft's Xbox One and Sony's PlayStation 4. Th ...
, Wii,
Xbox One The Xbox One is a home video game console developed by Microsoft. Announced in May 2013, it is the successor to Xbox 360 and the third base console in the Xbox series of video game consoles. It was first released in North America, parts of ...
and
Xbox 360 The Xbox 360 is a home video game console developed by Microsoft. As the successor to the original Xbox, it is the second console in the Xbox series. It competed with Sony's PlayStation 3 and Nintendo's Wii as part of the seventh generati ...
. The first public version of zlib, 0.9, was released on 1 May 1995 and was originally intended for use with the libpng image library. It is
free software Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
, distributed under the zlib License.


Capabilities


Encapsulation

zlib compressed data are typically written with a gzip or a zlib wrapper. The wrapper encapsulates the raw DEFLATE data by adding a header and trailer. This provides stream identification and error detection that are not provided by the raw DEFLATE data. The gzip header, used in the ubiquitous
gzip gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and i ...
file format, is larger than the zlib header, as it stores a file name and other file system information.


Algorithm

, zlib only supports one algorithm, called DEFLATE, which uses a combination of a variation of
LZ77 LZ77 and LZ78 are the two lossless data compression algorithms published in papers by Abraham Lempel and Jacob Ziv in 1977 and 1978. They are also known as LZ1 and LZ2 respectively. These two algorithms form the basis for many variations includin ...
(Lempel–Ziv 1977) and
Huffman coding In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding or using such a code proceeds by means of Huffman coding, an algo ...
. This algorithm provides good compression on a wide variety of data with minimal use of system resources. This is also the algorithm used in the Zip archive format. The header makes allowance for other algorithms, but none are currently implemented.


Resource use

zlib provides facilities for control of processor and memory use. A compression level value may be supplied that trades speed for compression. There are also facilities for conserving memory, useful in restricted memory environments, such as some embedded systems.


Strategy

The compression can be optimized for specific types of data. If one is using the library to always compress specific types of data, then using a specific strategy may improve compression and performance. For example, if the data contain long lengths of repeated bytes, the run-length encoding (RLE) strategy may give good results at a higher speed. For general data, the default strategy is preferred.


Error handling

Errors in compressed data may be detected and skipped. Further, if "full-flush" points are written to the compressed stream, then corrupt data can be skipped, and the decompression will resynchronize at the next flush point — although no error recovery of the corrupt data is provided. Full-flush points are useful for large data streams on unreliable channels, where some data loss is unimportant, such as in some multimedia applications. However, creating many flush points can affect the speed as well as the amount (ratio) of compression.


Data length

There is no limit to the length of data that can be compressed or decompressed. Repeated calls to the library allow an unlimited number of blocks of data to be handled. Some ancillary code (counters) may suffer from overflow for long data streams, but this does not affect the actual compression or decompression. When compressing a long (or infinite) data stream, it is advisable to write regular full-flush points.


Applications

Today, zlib is something of a ''
de facto ''De facto'' ( ; , "in fact") describes practices that exist in reality, whether or not they are officially recognized by laws or other formal norms. It is commonly used to refer to what happens in practice, in contrast with ''de jure'' ("by la ...
''
standard Standard may refer to: Symbols * Colours, standards and guidons, kinds of military signs * Standard (emblem), a type of a large symbol or emblem used for identification Norms, conventions or requirements * Standard (metrology), an object th ...
, to the point that zlib and DEFLATE are often used interchangeably in standards documents, with thousands of applications relying on it for compression, either directly or indirectly. These include: * The Linux kernel, where zlib is used to implement compressed network protocols, compressed file systems, and to decompress the kernel image at boot time. *
GNU Binutils The GNU Binary Utilities, or , are a set of programming tools for creating and managing binary programs, object files, libraries, profile data, and assembly source code. Tools They were originally written by programmers at Cygnus Solutions. ...
and
GNU Debugger The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, C, C++, Objective-C, Free Pascal, Fortran, Go, and partially others. History GDB was first written ...
(GDB) * libpng, the
reference implementation In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation o ...
for the PNG image format, which specifies DEFLATE as the stream compression for its
bitmap In computing, a bitmap is a mapping from some domain (for example, a range of integers) to bits. It is also called a bit array or bitmap index. As a noun, the term "bitmap" is very often used to refer to a particular bitmapping application: t ...
data. *
libwww Libwww was an early World Wide Web software library providing core functions for browsers, implementing HTML, HTTP, and other technologies. Tim Berners-Lee, at CERN, released libwww (then also called the "Common Library") in late 1992, comprising ...
, an API for Web applications like
Web browser A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's screen. Browsers are used o ...
s. * The Apache HTTP Server, which uses zlib to implement HTTP/1.1. * Similarly, the cURL library uses zlib to decompress HTTP responses. * The
OpenSSH OpenSSH (also known as OpenBSD Secure Shell) is a suite of secure networking utilities based on the Secure Shell (SSH) protocol, which provides a secure channel over an unsecured network in a client–server architecture. Network Working Gro ...
client and server, which rely on zlib to perform the optional compression offered by the
Secure Shell The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution. SSH applications are based on ...
protocol. * The OpenSSL and
GnuTLS GnuTLS (, the GNU Transport Layer Security Library) is a free software implementation of the TLS, SSL and DTLS protocols. It offers an application programming interface (API) for applications to enable secure communication over the network trans ...
security libraries, which can optionally use zlib to compress TLS connections. * The
FFmpeg FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the command-line ffmpeg tool itself, designed for processing of vid ...
multimedia library, which uses zlib to read and write the DEFLATE-compressed parts of stream formats, such as
Matroska Matroska is a project to create a container format that can hold an unlimited number of video, audio, picture, or subtitle tracks in one file. The Matroska Multimedia Container is similar in concept to other containers like AVI, MP4, or Advanc ...
. * The
rsync rsync is a utility for efficiently transferring and synchronizing files between a computer and a storage drive and across networked computers by comparing the modification times and sizes of files. It is commonly found on Unix-like opera ...
remote file synchronizer, which uses zlib to implement optional protocol compression. * The dpkg and RPM
package manager A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner. A package manager deals wi ...
s, which use zlib to unpack files from compressed software packages. * The
Apache Subversion Apache Subversion (often abbreviated SVN, after its command name ''svn'') is a software versioning and revision control system distributed as open source under the Apache License. Software developers use Subversion to maintain current and histo ...
and CVS
version control In software engineering, version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections o ...
systems, which use zlib to compress traffic to and from remote repositories. * The
Apache ORC The Apache () are a group of culturally related Native American tribes in the Southwestern United States, which include the Chiricahua, Jicarilla, Lipan, Mescalero, Mimbreño, Ndendahe (Bedonkohe or Mogollon and Nednhi or Carrizaleño an ...
column-oriented data storage format use ZLib as its default compression method. * The
Git Git () is a distributed version control system: tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data in ...
version control In software engineering, version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections o ...
system uses zlib to store the contents of its data objects (blobs, trees, commits and tags). * The PostgreSQL RDBMS uses zlib with custom dump format (pg_dump -Fc) for database backups. * The class System.IO.Compression.DeflateStream of the Microsoft
.NET Framework The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
2.0 and higher. * The "deflate" utility in TORNADO as part of
VxWorks VxWorks is a real-time operating system (or RTOS) developed as proprietary software by Wind River Systems, a wholly-owned subsidiary of Aptiv. First released in 1987, VxWorks is designed for use in embedded systems requiring real-time, determi ...
Operating System made by
Wind River Systems Wind River Systems, also known as Wind River (trademarked as Wndrvr), is an Alameda, California–based company, subsidiary of Aptiv PLC. The company develops embedded system and cloud software consisting of real-time operating systems software, ...
uses zlib to compress boot ROM images. * , raw zlib compression program, part o
qpdf
* The
MySQL MySQL () is an open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A relational database ...
RDBMS uses ZLib LZ77 for compression in
InnoDB InnoDB is a storage engine for the database management system MySQL and MariaDB. Since the release of MySQL 5.5.5 in 2010, it replaced MyISAM as MySQL's default table type. It provides the standard ACID-compliant transaction features, along ...
Tables zlib is also used in many embedded devices, such as the Apple iPhone and Sony
PlayStation 3 The PlayStation 3 (PS3) is a home video game console developed by Sony Computer Entertainment. The successor to the PlayStation 2, it is part of the PlayStation brand of consoles. It was first released on November 11, 2006, in Japan, November ...
, because the code is portable, liberally licensed, and has a relatively small memory footprint.


Forks

A commonly used library built on an old codebase, zlib is also frequently forked by third-parties that claim improvements to this library: *
Intel Intel Corporation is an American multinational corporation and technology company headquartered in Santa Clara, California. It is the world's largest semiconductor chip manufacturer by revenue, and is one of the developers of the x86 seri ...
has a high-performance fork of zlib. *
CloudFlare Cloudflare, Inc. is an American content delivery network and DDoS mitigation company, founded in 2009. It primarily acts as a reverse proxy between a website's visitor and the Cloudflare customer's hosting provider. Its headquarters are in Sa ...
maintains a high-performance fork with "massive" improvements.
Zlib-ng
is a zlib replacement fork with optimizations for "next generation" systems.


See also

* DEFLATE *
gzip gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and i ...
* LZ77 and LZ78 § LZ77 *
Zip (file format) ZIP is an archive file format that supports lossless data compression. A ZIP file may contain one or more files or directories that may have been compressed. The ZIP file format permits a number of compression algorithms, though DEFLATE is t ...
* zlib License * Zopfli


References


External links

* * — ZLIB Compressed Data Format * — DEFLATE Compressed Data Format * {{IETF RFC, 1952 —GZIP file format 1995 software C (programming language) libraries Free computer libraries Free data compression software Free software programmed in C Software using the zlib license