Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

compress (software)

From Wikipedia, the free encyclopedia
Compression shell command based on the LZW compression algorithm
"compress" redirects here. For the cloth used in medicine, seeCompress (medical). For other uses, seeCompression (disambiguation).
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Compress" software – news ·newspapers ·books ·scholar ·JSTOR
(June 2012) (Learn how and when to remove this message)
compress / uncompress
Original authorSpencer Thomas
Initial releaseFebruary 1985; 41 years ago (1985-02)
Operating systemUnix,Unix-like,IBM i
TypeCommand
compress .Z
Filename extension
.Z
Internet media type
application/x-compress
Developed bySpencer Thomas
Type of formatdata compression

compress is ashellcommand forcompressing data based on theLZW algorithm.[1]uncompress is a companion shell command that restores files to their original state (both content andmetadata) from a file created withcompress.

Although once popular,compress has fallen out of favor because it uses the patented LZW algorithm. Its use has been replaced by commands such asgzip andbzip2 that use other algorithms and provide better data compression. Compared togzip at its fastest setting,compress is slightly slower at compression, slightly faster at decompression, and has a significantly lowercompression ratio.[2] 1.8 MiB of memory is used to compress theHutter Prize data, slightly more thangzip at its slowest setting.[3]

compress anduncompress have maintained a presence onUnix andBSD systems and have been ported toIBM i.[4]

compress was standardized in X/Open CAE Specification in 1994,[5] and further in The Open Group Base Specifications, Issue 6 and 7.[6]Linux Standard Base does not requirecompress.[7]

compress is often excluded from the default installation of aLinux distribution but can be installed from a separate package.[8]compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX.

compress is allowed forPoint-to-Point Protocol inRFC 1977 and forHTTP/1.1 inRFC 9110, though it is rarely used in modern deployments as the better deflate/gzip is available.

Use

[edit]

Files compressed bycompress are typically named withextension ".Z" and therefore sometimes called .Z files. The extension derives from the earlierpack program which used extension ".z".

Mosttar implementations support compression bypiping data throughcompress when given the-Z command line option.

gunzip can decompress .Z files.[9]

Algorithm

[edit]

The LZW algorithm used incompress was patented bySperry Research Center in 1983.Terry Welch published an IEEE article on the algorithm in 1984,[10] but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of theUniversity of Utah took this article and implementedcompress in 1984, without realizing that a patent was pending on the LZW algorithm. TheGIF image format also incorporated LZW compression in this way, andUnisys 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 ofcompress and published it as free software to the net.sourcesUSENET group in 1985.U.S. patent 4,558,302 was granted in 1985 – makingcompress unusable without paying royalties to Sperry Research (which later merged into Unisys).

The US LZW patent expired in 2003, so it is now in the public domain in the United States. Today, all LZW patents worldwide are expired (seeGraphics Interchange Format#Unisys and LZW patent enforcement).

As ofPOSIX.1-2024compress supports theDEFLATE algorithm used ingzip.[11]

File format

[edit]

The compressed output 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 thencompress GitHub repository.[12]

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).

The existence of padding bits is actually a bug, as LZW does not require any alignment. This bug existed for more than 35 years and was in the original UNIXcompress,ncompress,gzip and the Windows port. Allapplication/x-compress files were created using this bug.

Somecompress 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.

See also

[edit]

References

[edit]
  1. ^Frysinger, Mike."ncompress: a public domain project". Retrieved2014-07-30.Compress is a fast, simple LZW file compressor. Compress does not have the highest compression rate, but it is one of the fastest programs to compress data. Compress is the de facto standard in the UNIX community for compressing files.
  2. ^Gommans, Luc."compression - What's the difference between gzip and compress?".Unix & Linux Stack Exchange.
  3. ^"Large Text Compression Benchmark".mattmahoney.net.compress 4.3d....
  4. ^IBM."IBM System i Version 7.2 Programming Qshell"(PDF).IBM. Retrieved2020-09-05.
  5. ^X/Open CAE Specification Commands and Utilities Issue 4, Version 2 (pdf), 1994, opengroup.org
  6. ^compress – Shell and Utilities Reference,The Single UNIX Specification, Version 3 fromThe Open Group
  7. ^Chapter 17. Commands and Utilities in Linux Standard Base Core Specification 5.0.0, linuxfoundation.org
  8. ^ncompress, pkgs.org
  9. ^"GNU Gzip".The GNU Operating System and the Free Software Movement. 2023-02-05. Retrieved2024-04-03.gunzip can currently decompress files created by gzip, zip, compress or pack. The detection of the input format is automatic.
  10. ^Welch, Terry A. (1984)."A technique for high performance data compression"(PDF).IEEE Computer.17 (6):8–19.doi:10.1109/MC.1984.1659158.S2CID 2055321.
  11. ^"compress". opengroup. Retrieved2 November 2024.
  12. ^"compression with 9 bits don't work · Issue #5 · vapier/ncompress".GitHub. Retrieved2024-09-17.

External links

[edit]
Archivers with
compression
(comparison)
Free and
open-source
Freeware
Commercial
Non-archiving
compressors
Generic
For code
Audio
compression

(comparison)
Lossy
Lossless
Video
compression

(comparison)
Lossy
MPEG-4 ASP
H.264
HEVC
Others
Lossless
Archiving only
Compressing only
Archiving
and compressing
Software packaging
and distributing
Document packaging
and distributing
Retrieved from "https://en.wikipedia.org/w/index.php?title=Compress_(software)&oldid=1305042970"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp