TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How are zlib, gzip and zip related?

300 pointsby damagednoobover 1 year ago

13 comments

cturover 1 year ago
What a great historical summary. Compression has moved on now but having grown up marveling at PKZip and maximizing usable space on very early computers, as well as compression in modems (v42bis ftw!), this field has always seemed magical.<p>These days it generally is better to prefer Zstandard to zlib&#x2F;gzip for many reasons. And if you need seekable format, consider squashfs as a reasonable choice. These stand on the shoulders of the giants of zlib and zip but do indeed stand much higher in the modern world.
评论 #38436605 未加载
评论 #38438764 未加载
评论 #38439165 未加载
emmelaichover 1 year ago
Fun fact: in a sense. gzip can have multiple files, but not in a specially useful way ...<p><pre><code> $ echo meow &gt;cat $ echo woof &gt; dog $ gzip cat $ gzip dog $ cat cat.gz dog.gz &gt;animals.gz $ gunzip animals.gz $ cat animals meow woof</code></pre>
评论 #38436630 未加载
评论 #38441425 未加载
评论 #38441153 未加载
评论 #38438800 未加载
coutover 1 year ago
Interesting -- I did not realize that the zip format supports lzma, bzip2, and zstd. What software supports those compression methods? Can Windows Explorer read zip files produced with those compression methods?<p>(I have been using 7zip for about 15 years to produce archive files that have an index and can quickly extract a single file and can use multiple cores for compression, but I would love to have an alternative, if one exists).
评论 #38434791 未加载
评论 #38435467 未加载
melagonsterover 1 year ago
For people who first read this: the sweet part is in the comments :)
评论 #38432519 未加载
评论 #38434333 未加载
评论 #38481436 未加载
dustypotatoover 1 year ago
Found this hilarious:<p>&gt; This post is packed with so much history and information that I feel like some citations need be added<p>&gt; I am the reference<p>(extracted a part of the conversation)
评论 #38432782 未加载
评论 #38433774 未加载
评论 #38433143 未加载
评论 #38433462 未加载
HexDecOctBinover 1 year ago
Is there an archive format that supports appending diff&#x27;s of an existing file, so that multiple versions of the same file are stored? PKZIP has a proprietary extension (supposedly), but I couldn&#x27;t find any open version of that.<p>(I was thinking of a creating a version control system whose .git directory equivalent is basically an archive file that can easily be emailed, etc.)
评论 #38440913 未加载
kissgyorgyover 1 year ago
If you are interested in implementation details, how to unpack&#x2F;decompress them, check out these Python implementations:<p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handlers&#x2F;archive&#x2F;zip.py">https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handle...</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handlers&#x2F;compression&#x2F;gzip.py">https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handle...</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handlers&#x2F;compression&#x2F;zlib.py">https:&#x2F;&#x2F;github.com&#x2F;onekey-sec&#x2F;unblob&#x2F;blob&#x2F;main&#x2F;unblob&#x2F;handle...</a>
wiredfoolover 1 year ago
The real question is: how are zlib and libz related?
评论 #38434565 未加载
expositionover 1 year ago
There&#x27;s also pzip&#x2F;punzip (<a href="https:&#x2F;&#x2F;github.com&#x2F;ybirader">https:&#x2F;&#x2F;github.com&#x2F;ybirader</a>) for those wanting more performant (concurrent) zip&#x2F;unzip.<p>Disclaimer: I&#x27;m the author.
Dweditover 1 year ago
See a highly upvoted answer in a question about zlib related things, suspect it was probably posted by Mark Adler, and turn out to be correct.
raggiover 1 year ago
The answer is good, but is missing a key section:<p>Salty form: They&#x27;re all quite slow compared to modern competitors.
评论 #38438226 未加载
readyplayernullover 1 year ago
gzip can be used to (de)compress directories recursively in a variable:<p>FOO=$(tar cf - folderToCompress | gzip | base64)<p>echo $FOO | base64 - d | zcat | tar xf -
encomover 1 year ago
(2013)