给定一个解压缩的 gzip 文件,有没有办法重新创建确切的原始 gzip 文件?

发布于 2024-09-13 13:12:59 字数 236 浏览 2 评论 0原文

给定一个 gzip 文件 Z,如果我将其解压缩到 Z',有什么方法可以重新压缩它以获得完全相同相同的 gzip 文件 Z?粗略阅读 DEFLATE 格式后,我猜不会,因为任何给定文件都可能有 DEFLATE 流格式的多种表示形式,并且无法确定最初使用的是哪一个。任何人都可以确认这个推理是否正确,如果不正确,请指出我该怎么做?

为了加分,哪些压缩算法/格式被严格指定,以至于文件只有一种压缩表示形式?

谢谢!

Given a gzip file Z, if I decompress it to Z', is there any way I can recompress it to get the exact same gzip file Z back? After a cursory reading of the DEFLATE format, I am guessing no, as any given file may have multiple representations in DEFLATE stream format, and there is no way to determine which one was originally used. Can anybody confirm whether this reasoning is correct, and if not, point out how I can do this?

For bonus points, which compression algorithms/formats are tightly specified enough that there is only ever one compressed representation of a file?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落日海湾 2024-09-20 13:13:27

对于 gzip 来说绝对不行,除非您也知道所涉及的工具和参数(甚至可能知道)。

考虑到所涉及的权衡,我不明白为什么这是可取的,因为用户无法平衡不同的关注点。我不想在网络服务器上使用相同的参数来动态执行 gzip 进行内容编码或传输编码,就像我在酒吧里高兴地让机器在一夜之间完成工作时压缩大量档案一样。

Definitely no for gzip, unless you also know the tools and parameters involved (and maybe even then).

Considering the trade-offs involved, I don't see why this would be desirable, as the user couldn't balance different concerns. I would not want to have the same parameters used to do gzip on the fly on a webserver for content-encoding or transfer-encoding as I would for zipping up a massive archive while I am happily in the pub letting the machine do its job overnight.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文