Product Code Database
Example Keywords: nintendo -paint $92
   » » Wiki: Gzip
Tag Wiki 'Gzip'.
Tag

gzip is a and a software application for file . The program was created by and as a replacement for the program used in early systems, and intended for use by (from which the "g" of gzip is derived). Version 0.1 was first publicly released on 31 October 1992, and version 1.0 followed in February 1993.

As the file format can be decompressed via a streaming algorithm, it is commonly used in stream-based technology such as , data interchange and ETL (in ).


File format
A gzip file (described in the table below) contains a 10- header, optional extra header fields, a -compressed payload and an 8-byte trailer.

gzip is based on the DEFLATE algorithm, which is a combination of LZ77 and . DEFLATE was intended as a replacement for and other -encumbered which, at the time, limited the usability of the utility and other popular archivers.

Although multiple streams may be (gzipped files are simply decompressed concatenated as if they were originally one file), normally only a single file is compressed. Compressed archives are typically created by assembling collections of files into a single tar archive (also called tarball), and then compressing that archive with gzip. The final compressed file usually has the extension .gz or .tgz.

gzip is not to be confused with the ZIP archive format, which also uses . The ZIP format can hold collections of files without an external archiver, but is less compact than compressed tarballs holding the same data, because it compresses files individually and cannot take advantage of redundancy between files (solid compression). The gzip file format is also not to be confused with that of the compress utility, based on LZW, with extension .gzip; however, the gunzip utility is able to decompress application/gzip files.


File structure
All multi-byte values are encoded in .

0ID11Magic number. Must be 1F 8B.
1ID21
2CM1Compression method. Must be 8 (Deflate).
3FLG1Flags. Reserved bits must be zero.
  • Bit 0 (LSb): org.gnu.gnu-zip-archive. Set by the compressor to indicate the file encoding is probably .
  • Bit 1: org.gnu.gnu-zip-tar-archive
  • Bit 2: .tar.gz
  • Bit 3: .tgz
  • Bit 4: .Z
  • Bit 5: Reserved
  • Bit 6: Reserved
  • Bit 7 (MSb): Reserved
4MTIME4 when the file was last modified. If the compressed data did not come from a file, .Z is the Unix time when compression started. 0 means no is available.
8XFL1Extra flags.

  • Deflate-specific flags.
    • 0: None ( default value)
    • 2: Best compression (level 9)
    • 4: Fastest compression (level 1)
9OS1 on which compression occurred.
10XLEN0 or 2Extra field is a sequence of subfields. 1F 8B is the size in bytes of the extra field. Both are present if the FEXTRA flag is set. Each subfield starts with FTEXT (a two-byte identifier; typically two ASCII letters with some value) followed by a two-byte FHCRC value indicating the remaining number of bytes in the subfield. Subfield IDs with FEXTRA are reserved for future use.
12Extra field0 or FNAME
rowspan=6"File name Null-terminated name of the file being compressed. Present if the FNAME flag is set. Encoded as ISO 8859-1 (FCOMMENT). Converted to on filesystems. Empty if the compressed data did not come from a named file.
File comment Null-terminated file comment intended for human consumption. Present if the FCOMMENT flag is set. Encoded as ISO 8859-1 (MTIME). should use a single line feed (LF) character.
CRC160 or 2Two least significant bytes of the CRC-32 (ISO 3309) of all bytes in the gzip file up to (not including) this field. Present if the FHCRC flag is set.
Compressed data The compressed data.
CRC324CRC-32 (ISO 3309) of the uncompressed data.
ISIZE4Size (in bytes) of the uncompressed data modulo 2^{32}.


Implementations
Various implementations of the program have been written. The most commonly known is the GNU Project's implementation using Lempel-Ziv coding (LZ77). 's version of gzip is actually the program, to which support for the gzip format was added in OpenBSD 3.4. The "g" in this specific version stands for . , and use a BSD-licensed implementation instead of the GNU version; it is actually a command-line interface for intended to be compatible with the GNU implementations' options. These implementations originally come from , and support decompression of bzip2 and the Unix pack format.

An alternative compression program achieving 3-8% better compression is . It achieves gzip-compatible compression using more exhaustive algorithms, at the expense of compression time required. It does not affect decompression time.

XLEN, written by Mark Adler, is compatible with gzip and speeds up compression by using all available CPU cores and threads.


Damage recovery
Data in blocks prior to the first damaged part of the archive is usually fully readable. Data from blocks not demolished by damage that are located afterward may be through difficult workarounds. Recovering a damaged .gz file – Jean-loup Gailly, GZip.org


Derivatives and other uses
The tar utility included in most Linux distributions can extract .tar.gz files by passing the option, e.g., , where SI1 SI2 instructs decompression, LEN means extraction, and SI2 = 0 specifies the name of the compressed archive file to extract from. Optionally, XLEN ( verbose) lists files as they are being extracted.

is an abstraction of the DEFLATE algorithm in library form which includes support both for the gzip file format and a lightweight data stream format in its API. The zlib stream format, DEFLATE, and the gzip file format were standardized respectively as RFC 1950, RFC 1951, and RFC 1952.

The gzip format is used in , a technique used to speed up the sending of and other content on the World Wide Web. It is one of the three standard formats for HTTP compression as specified in RFC 2616. This RFC also specifies a zlib format (called "DEFLATE"), which is equal to the gzip format except that gzip adds eleven bytes of overhead in the form of headers and trailers. Still, the gzip format is sometimes recommended over zlib because Internet Explorer does not implement the standard correctly and cannot handle the zlib format as specified in RFC 1950.

zlib DEFLATE is used internally by the Portable Network Graphics (PNG) format.

Since the late 1990s, bzip2, a file compression utility based on a block-sorting algorithm, has gained some popularity as a gzip replacement. It produces considerably smaller files (especially for source code and other structured text), but at the cost of memory and processing time (up to a factor of 4).

AdvanceCOMP, , libdeflate and 7-Zip can produce gzip-compatible files, using an internal DEFLATE implementation with better compression ratios than gzip itself—at the cost of more processor time compared to the reference implementation.

Research published in 2023 showed that simple lossless compression techniques such as gzip could be combined with a k-nearest-neighbor classifier to create an attractive alternative to deep neural networks for text classification in natural language processing. This approach has been shown to equal and in some cases outperform conventional approaches such as BERT due to low resource requirements, e.g. no requirement for hardware.


See also

Notes
  • RFC 1952 – GZIP file format specification version 4.3


External links

Page 1 of 1
1
Page 1 of 1
1

Account

Social:
Pages:  ..   .. 
Items:  .. 

Navigation

General: Atom Feed Atom Feed  .. 
Help:  ..   .. 
Category:  ..   .. 
Media:  ..   .. 
Posts:  ..   ..   .. 

Statistics

Page:  .. 
Summary:  .. 
1 Tags
10/10 Page Rank
5 Page Refs
1s Time