Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

compression - 如何将zlib,gzip和zip相关联?它们有什么共同之处,它们有何不同?(How are zlib, gzip and zip related? What do they have in common and how are they different?)

The compression algorithm used in zlib is essentially the same as that in gzip and zip .

(zlib中使用的压缩算法与gzipzip中的压缩算法基本相同。)

What are gzip and zip ?

(什么是gzipzip ?)

How are they different and how are they same?

(它们有何不同,它们是如何相同的?)

  ask by Abhishek Jain translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Short form:

(简写:)

.zip is an archive format using, usually, the Deflate compression method .

(.zip是一种归档格式 ,通常使用Deflate压缩方法 。)

The .gz gzip format is for single files, also using the Deflate compression method.

(.gz gzip格式适用于单个文件,也使用Deflate压缩方法。)

Often gzip is used in combination with tar to make a compressed archive format , .tar.gz .

(gzip通常与tar结合使用,以生成压缩的归档格式 .tar.gz 。)

The zlib library provides Deflate compression and decompression code for use by zip, gzip, png (which uses the zlib wrapper on deflate data), and many other applications.

(zlib库提供了Deflate压缩和解压缩代码,供zip,gzip, png (使用defl数据上的zlib包装器 )和许多其他应用程序使用。)

Long form:

(长表:)

The ZIP format was developed by Phil Katz as an open format with an open specification, where his implementation, PKZIP, was shareware.

(ZIP格式是由Phil Katz开发的一种开放格式,具有开放式规范,其实现PKZIP是共享软件。)

It is an archive format that stores files and their directory structure, where each file is individually compressed.

(它是一种存档格式,用于存储文件及其目录结构,其中每个文件都是单独压缩的。)

The file type is .zip .

(文件类型是.zip 。)

The files, as well as the directory structure, can optionally be encrypted.

(可以选择加密文件以及目录结构。)

The ZIP format supports several compression methods:

(ZIP格式支持多种压缩方法:)

0 - The file is stored (no compression)
1 - The file is Shrunk
2 - The file is Reduced with compression factor 1
3 - The file is Reduced with compression factor 2
4 - The file is Reduced with compression factor 3
5 - The file is Reduced with compression factor 4
6 - The file is Imploded
7 - Reserved for Tokenizing compression algorithm
8 - The file is Deflated
9 - Enhanced Deflating using Deflate64(tm)
10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
11 - Reserved by PKWARE
12 - File is compressed using BZIP2 algorithm
13 - Reserved by PKWARE
14 - LZMA (EFS)
15 - Reserved by PKWARE
16 - Reserved by PKWARE
17 - Reserved by PKWARE
18 - File is compressed using IBM TERSE (new)
19 - IBM LZ77 z Architecture (PFS)
97 - WavPack compressed data
98 - PPMd version I, Rev 1

Methods 1 to 7 are historical and are not in use.

(方法1至7是历史的并且未使用。)

Methods 9 through 98 are relatively recent additions, and are in varying, small amounts of use.

(方法9至98是相对较新的添加物,并且具有不同的少量使用。)

The only method in truly widespread use in the ZIP format is method 8, Deflate , and to some smaller extent method 0, which is no compression at all.

(在ZIP格式中真正广泛使用的唯一方法是方法8, Deflate ,以及一些较小范围的方法0,它根本不压缩。)

Virtually every .zip file that you will come across in the wild will use exclusively methods 8 and 0, likely just method 8. (Method 8 also has a means to effectively store the data with no compression and relatively little expansion, and Method 0 cannot be streamed whereas Method 8 can be.)

(实际上,您将在野外遇到的每个.zip文件都将使用方法8和0,可能只是方法8.(方法8也有一种方法可以有效地存储数据而不进行压缩和相对较少的扩展,而方法0不能流式传输,而方法8可以。))

The ISO/IEC 21320-1:2015 standard for file containers is a restricted zip format, such as used in Java archive files (.jar), Office Open XML files (Microsoft Office .docx, .xlsx, .pptx), Office Document Format files (.odt, .ods, .odp), and EPUB files (.epub).

(文件容器ISO / IEC 21320-1:2015标准是受限制的zip格式,例如用于Java归档文件(.jar),Office Open XML文件(Microsoft Office .docx,.xlsx,.pptx),Office文档格式化文件(.odt,.ods,.odp)和EPUB文件(.epub)。)

That standard limits the compression methods to 0 and 8, as well as other constraints such as no encryption or signatures.

(该标准将压缩方法限制为0和8,以及其他约束,如无加密或签名。)

Around 1990, the Info-ZIP group wrote portable, free, open source implementations of zip and unzip utilities, supporting compression with the Deflate format, and decompression of that and the earlier formats.

(大约在1990年, Info-ZIP小组编写了zipunzip实用程序的可移植,免费,开源实现,支持使用Deflate格式进行压缩,以及对该格式和早期格式进行解压缩。)

This greatly expanded the use of the .zip format.

(这极大地扩展了.zip格式的使用。)

In the early 90's, the gzip format was developed as a replacement for the Unix compress utility , derived from the Deflate code in the Info-ZIP utilities.

(在90年代早期, gzip格式被开发为Unix compress实用程序的替代品,它源自Info-ZIP实用程序中的Deflate代码。)

Unix compress was designed to compress a single file or stream, appending a .Z to the file name.

(Unix compress旨在压缩单个文件或流,将.Z附加到文件名。)

compress uses the LZW compression algorithm , which at the time was under patent and its free use was in dispute by the patent holders.

(compress使用LZW压缩算法 ,该算法当时属于专利,其免费使用受到专利持有人的争议。)

Though some specific implementations of Deflate were patented by Phil Katz, the format was not, and so it was possible to write a Deflate implementation that did not infringe on any patents.

(虽然Deflate的一些具体实现是由Phil Katz申请专利的,但格式不是,所以有可能编写一个不侵犯任何专利的Deflate实现。)

That implementation has not been so challenged in the last 20+ years.

(在过去的20多年里,这种实施并未受到如此严峻的挑战。)

The Unix gzip utility was intended as a drop-in replacement for compress , and in fact is able to decompress compress -compressed data (assuming that you were able to parse that sentence).

(Unix gzip实用程序旨在作为compress替代品,实际上能够解compress数据(假设您能够解析该句子)。)

gzip appends a .gz to the file name.

(gzip.gz附加到文件名。)

gzip uses the Deflate compressed data format, which compresses quite a bit better than Unix compress , has very fast decompression, and adds a CRC-32 as an integrity check for the data.

(gzip使用Deflate压缩数据格式,压缩比Unix compress更好,具有非常快速的解压缩,并添加CRC-32作为数据的完整性检查。)

The header format also permits the storage of more information than the compress format allowed, such as the original file name and the file modification time.

(标头格式还允许存储比允许的compress格式更多的信息,例如原始文件名和文件修改时间。)

Though compress only compresses a single file, it was common to use the tar utility to create an archive of files, their attributes, and their directory structure into a single .tar file, and to then compress it with compress to make a .tar.Z file.

(虽然compress仅压缩单个文件,这是通常使用的tar实用程序创建的文件,它们的属性,以及它们的目录结构的归档到一个单一.tar文件,并然后用它压缩compress做出.tar.Z档。)

In fact the tar utility had and still has an option to do the compression at the same time, instead of having to pipe the output of tar to compress .

(事实上, tar实用程序已经并且仍然可以选择同时进行压缩,而不必管道tar的输出进行compress 。)

This all carried forward to the gzip format, and tar has an option to compress directly to the .tar.gz format.

(这一切都转移到gzip格式, tar有一个选项可以直接压缩到.tar.gz格式。)

The <

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...