Compress (software)

Revision as of 21:54, 2 February 2025 by 104.187.53.245 (talk) (→‎External links: Removed old domain that no longer has related content)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description Template:Redirect Template:More citations needed Template:Lowercase title {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other Template:Infobox file format compress is a Unix shell compression program based on the LZW compression algorithm.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> Compared to gzip's fastest setting, compress is slightly slower at compression, slightly faster at decompression, and has a significantly lower compression ratio.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> 1.8 MiB of memory is used to compress the Hutter Prize data, slightly more than gzip's slowest setting.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

The uncompress utility will restore files to their original state after they have been compressed using the compress utility. If no files are specified, the standard input will be uncompressed to the standard output.


DescriptionEdit

Files compressed by compress are typically given the extension ".Z" (modeled after the earlier pack program which used the extension ".z"). Most tar programs will pipe their data through compress when given the command line option "-Z". (The tar program in its own does not compress; it just stores multiple files within one tape archive.)

Files can be returned to their original state using uncompress. The usual action of uncompress is not merely to create an uncompressed copy of the file, but also to restore the timestamp and other attributes of the compressed file.

For files produced by compress on other systems, uncompress supports 9- to 16-bit compression.

HistoryEdit

The LZW algorithm used in Template:Mono was patented by Sperry Research Center in 1983. Terry Welch published an IEEE article on the algorithm in 1984,<ref>Template:Cite journal</ref> but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of the University of Utah took this article and implemented Template:Mono in 1984, without realizing that a patent was pending on the LZW algorithm. The GIF image format also incorporated LZW compression in this way, and Unisys later claimed royalties on implementations of GIF. Joseph M. Orost led the team and worked with Thomas et al. to create the 'final' (4.0) version of Template:Mono and published it as free software to the 'net.sources' USENET group in 1985. {{#if:4558302 |[{{#ifeq:|uspto|http://patft.uspto.gov/netacgi/nph-Parser?patentnumber=%7Chttps://patents.google.com/patent/US}}{{#iferror:{{#expr:4558302 }}|4558302}} U.S. patent {{#ifeq:Template:Replace|Template:Digits|Template:Replace|4558302}}] |{{US patent|123456|link text}}}} was granted in 1985, and this is why Template:Mono could not be used without paying royalties to Sperry Research, which was eventually merged into Unisys.

Template:Mono has fallen out of favor in particular user-groups because it makes use of the LZW algorithm, which was covered by a Unisys patentTemplate:Sndbecause of this, gzip and bzip2 increased in popularity on Linux-based operating systems due to their alternative algorithms, along with better file compression. compress has, however, maintained a presence on Unix and BSD systems and the Template:Mono and Template:Mono commands have also been ported to the IBM i operating system.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

The US LZW patent expired in 2003, so it is now in the public domain in the United States. All patents on the LZW worldwide have also expired (see Graphics Interchange Format#Unisys and LZW patent enforcement).

As of POSIX.1-2024 compress supports the DEFLATE algorithm used in gzip.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Special output formatEdit

The output binary consists of bit groups. Each bit group consists of codes with fixed amount of bits (9–16). Each group, except the last group, is aligned to the number of bits per code multiplied by 8 and right padded with zeroes. The last group is aligned to 8 bit octets and padded with zeroes. More information can be found at an issue on the ncompress GitHub repository.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

Example:

Suppose the output has ten 9-bit codes, five 10-bit codes, and thirteen 11-bit codes. There are three groups to output containing 90 bits, 50 bits, and 143 bits of data.
  • First group will be 90 bits of data + 54 zero bits of padding in order to be aligned to 72 bits (9 bits × 8).
  • Second group will be 50 bits of data + 30 zero bits of padding in order to be aligned to 80 bits (10 bits × 8).
  • Third group will be 143 bits of data + 1 zero bit of padding in order to be aligned to 8 bits (since this is the last group in the output).

ItTemplate:What is actually a bug. LZW does not require any alignment. This bug existed for more than 35 years and was in the original UNIX compress, ncompress, gzip and the Windows port. All application/x-compress files were created using this bug.

Some compress implementations write random bits from uninitialized buffer in paddings. There is no guarantee that the paddings will be zeroes. The decompressor must ignore the values in the paddings for compatibility.

Standardization and availabilityEdit

compress was standardized in X/Open CAE Specification in 1994,<ref>X/Open CAE Specification Commands and Utilities Issue 4, Version 2 (pdf), 1994, opengroup.org</ref> and further in The Open Group Base Specifications, Issue 6 and 7.<ref>Template:Man</ref> Linux Standard Base does not requires compress.<ref>Chapter 17. Commands and Utilities in Linux Standard Base Core Specification 5.0.0, linuxfoundation.org</ref>

compress is often not installed by default in Linux distributions, but can be installed from an additional package.<ref>ncompress, pkgs.org</ref> compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX.

compress is allowed for Point-to-Point Protocol in Template:IETF RFC and for HTTP/1.1 in Template:IETF RFC, though it is rarely used in modern deployments as the better deflate/gzip is available.

The gunzip utility is able to decompress .Z files.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref>

See alsoEdit

ReferencesEdit

Template:Reflist

External linksEdit

Template:Compression Software ImplementationsTemplate:Archive formats