compress (software)
This articleneeds additional citations forverification.(June 2012) |
Original author(s) | Spencer Thomas |
---|---|
Initial release | February 1985 |
Operating system | Unix,Unix-like,IBM i |
Type | Command |
Filename extension |
.Z |
---|---|
Internet media type |
application/x-compress |
Developed by | Spencer Thomas |
Type of format | data compression |
compressis aUnix shellcompression programbased on theLZWcompression algorithm.[1]Compared togzip's 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 Prizedata, slightly more than gzip's slowest setting.[3]
Theuncompressutility will restore files to their original state after they have been compressed using thecompressutility. If no files are specified, thestandard inputwill be uncompressed to the standard output.
In the upcomingPOSIXandSingle Unix Specificationrevision, it is planned thatDEFLATEalgorithm used ingzipformat be supported in those utilities.[4]
Description
[edit]Files compressed bycompressare typically given theextension".Z" (modeled after the earlierpackprogram which used theextension".z" ). Mosttarprograms willpipetheir data throughcompresswhen given the command line option "-Z
".(Thetarprogram in its own does not compress; it just stores multiple files within one tape archive.)
Files can be returned to their original state usinguncompress.The usual action ofuncompressis 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 bycompresson other systems,uncompresssupports 9- to 16-bit compression.
History
[edit]The LZW algorithm used incompresswas patented bySperry Research Centerin 1983.Terry Welchpublished an IEEE article on the algorithm in 1984,[5]but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of theUniversity of Utahtook this article and implementedcompressin 1984, without realizing that a patent was pending on the LZW algorithm. TheGIFimage format also incorporated LZW compression in this way, andUnisyslater 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 ofcompressand published it as free software to the 'net.sources'USENETgroup in 1985.U.S. patent 4,558,302was granted in 1985, and this is whycompresscould not be used without paying royalties to Sperry Research, which was eventually merged into Unisys.
compresshas fallen out of favor in particular user-groups because it makes use of the LZW algorithm, which was covered by a Unisys patent – because of this,gzipandbzip2increased in popularity onLinux-based operating systems due to their alternative algorithms, along with better file compression.compresshas, however, maintained a presence onUnixandBSDsystems and thecompressanduncompresscommands have also been ported to theIBM ioperating system.[6]
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 (seeGraphics Interchange Format#Unisys and LZW patent enforcement).
In the up-comingPOSIXandSingle Unix Specificationrevision, it is planned thatDEFLATEalgorithm used ingzipformat be supported in those utilities.
Special output format
[edit]Output binary consists of bit groups. Each bit group consists of codes with fixed amount of bits (9-16). Each group (except last) should be aligned by amount of bits multiplied by 8 and right padded with zeroes. Last group should be aligned by 8 and padded with zeroes. You can find more information in ncompressissue.
Example:
- You want to output ten 9-bit codes, five 10-bit codes and thirteen 11-bit codes. You now have three groups of bits that you want to output: 90 bits, 50 bits and 143 bits.
- First group should then be 90 bits of data + 54 zero bits of padding in order to be aligned to 72 bits (9 bits × 8).
- Second group should then be 50 bits of data + 30 zero bits of padding in order to be aligned to 80 bits (10 bits × 8).
- Third group should then be 143 bits of data + 1 zero bit of padding in order to be aligned to 8 bits (1 byte only, since this is the last group in the output).
It is actually a bug. LZW doesn't require any alignment. This bug is a part of original UNIX compress, ncompress, gzip and even windows port. It exists more than 35 years. Allapplication/x-compressfiles were created using this bug. So we have to include it in output specification.
Some compress implementations write random bits from uninitialized buffer as alignment bits. There is no guarantee that alignment bits will be zeroes. So in terms of 100% compatibility decompressor have to just ignore alignment bit values.
Standardization and availability
[edit]compress was standardized in X/Open CAE Specification in 1994,[7]and further in The Open Group Base Specifications, Issue 6 and 7.[8]Linux Standard Basedoes not requires compress.[9]
compress is often not installed by default in Linux distributions, but can be installed from an additional package.[10]compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX.
compress is allowed forPoint-to-Point ProtocolinRFC1977and forHTTP/1.1inRFC9110,though it is rarely used in modern deployments as the better deflate/gzip is available.
The gunzip utility is able to decompress.Z files.[11]
See also
[edit]References
[edit]- ^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.
- ^Gommans, Luc."compression - What's the difference between gzip and compress?".Unix & Linux Stack Exchange.
- ^"Large Text Compression Benchmark".mattmahoney.net.
compress 4.3d....
- ^"0001041: Encourage implementations to include better integrity checksum, compression and decompression utilities if possible".Austin Group Bug Tracker.Retrieved2017-11-23.
- ^Welch, Terry A.(1984)."A technique for high performance data compression"(PDF).IEEE Computer.17(6): 8–19.doi:10.1109/MC.1984.1659158.S2CID2055321.
- ^IBM."IBM System i Version 7.2 Programming Qshell"(PDF).IBM.Retrieved2020-09-05.
- ^X/Open CAE Specification Commands and Utilities Issue 4, Version 2(pdf), 1994, opengroup.org
- ^The Single UNIX Specification,Version 3 fromThe Open Group – Shell and Utilities Reference,
- ^Chapter 17. Commands and Utilitiesin Linux Standard Base Core Specification 5.0.0, linuxfoundation.org
- ^ncompress,pkgs.org
- ^"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.
External links
[edit]- The Single UNIX Specification,Version 4 fromThe Open Group :compress data – Shell and Utilities Reference,
- Version 8 UnixProgrammer'sManual –
- FreeBSDGeneral CommandsManual –
- OpenBSDGeneral CommandsManual –
- Solaris 11.4User Commands ReferenceManual –
- ncompress- public domain compress/uncompress implementation for POSIX systems
- compress- original Unix compress (in a compress'd archive)
- compress- original Unix compress executable (gzip'd)
- Source Code for compress v4.0(gzip'd sharchives)
- ZIP File containing a Windows port of the compress utility
- source code to the current version of fcompress.c from compress
- bit groups alignment- Explanation of bit groups alignment.
- lzws- New library and CLI, implemented without legacy code.
- ruby-lzws- Ruby bindings with streaming support.
- compress- official website for file compression.