如何确定 ZIP/RAR 文件的压缩方法
我正在使用一些 zip 和 rar 文件,我正在尝试分析每个文件的压缩方式的属性(压缩级别、压缩算法(例如 deflate、LZMA、BZip2)、字典大小、字长等),而且我还没有找到一种方法来做到这一点。
有没有办法通过软件或其他方式分析文件以确定这些属性?
干杯和感谢!
I have a few zip and rar files that I'm working with, and I'm trying to analyze the properties of how each file was compressed (compression level, compression algorithm (e.g. deflate, LZMA, BZip2), dictionary size, word size, etc.), and I haven't figured out a way to do this yet.
Is there any way to analyze the files to determine these properties, with software or otherwise?
Cheers and thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这是一个相当老的问题,但无论如何我想投入我的两分钱,因为上面的一些方法对我来说并不容易使用。
您还可以使用 7-Zip 来确定这一点。打开存档后,有一列压缩方法:
This is a fairly old question, but I wanted to throw in my two cents anyway since some of the methods above weren't as easy for me to use.
You can also determine this with 7-Zip. After opening the archive there is a column for method of compression:
对于 ZIP - 是的,zipinfo
对于 RAR,可以使用 7Zip 或 WinRAR 轻松找到标头,请阅读随附的文档
For ZIP - yes, zipinfo
For RAR, the headers are easily found with either 7Zip or WinRAR, read the attached documentation
通过 7-Zip(或 p7zip)命令行:
如果专门寻找压缩方法:
Via 7-Zip (or p7zip) command line:
If looking specifically for the compression method:
我建议 hachoir-wx 查看这些文件。 如何安装 Python 包 或者您使用 Windows 时,可以尝试使用 PyPM ActivePython 。安装必要的 hachoir 软件包后,您可以执行以下操作来运行 GUI:
它使您能够浏览 RAR 和 ZIP 文件的数据字段。有关示例,请参阅此屏幕截图。
对于 RAR 文件,请查看 technote.txt 文件它位于 WinRAR 安装目录中。这提供了 RAR 规范的详细信息。您可能会对这些感兴趣:
字典大小也可以在 WinRAR GUI 中找到。
维基百科也知道这一点:
对于 ZIP 文件,我首先查看 规范 和 ZIP 维基百科页面。这些可能很有趣:
I suggest hachoir-wx to have a look at these files. How to install a Python package or you can try ActivePython with PyPM when using Windows. When you have the necessary hachoir packages installed, you can do something like this to run the GUI:
It enables you to browse through the data fields of RAR and ZIP files. See this screenshot for an example.
For RAR files, have a look at the technote.txt file that is in the WinRAR installation directory. This gives detailed information of the RAR specification. You will probably be interested in these:
Dictionary size can be found in the WinRAR GUI too.
And Wikipedia also knows this:
For ZIP files I would start by having a look at the specifications and the ZIP Wikipedia page. These are probably interesting:
zipfile python 模块可用于获取有关 zip 文件的信息。
ZipInfo
类提供诸如filename
、compress_type
、compress_size
、file_size
等信息。 ..用于获取 zip 存档中文件名和文件压缩类型的 Python 代码片段
这将列出所有文件名及其相应的压缩类型(整数),可用于查找压缩方法。
您可以使用 infolist 获取有关文件的更多信息 ()。
接受的答案中链接的 python 模块不可用,
zipfile
模块可能有帮助The zipfile python module can be used to get info about the zipfile.
The
ZipInfo
class provides information likefilename
,compress_type
,compress_size
,file_size
etc...Python snippet to get filename and the compress type of files in a zip archive
This would list all the filenames and their corresponding compression type(integer), which can be used to look up the compression method.
You can get a lot more info about the files using infolist().
The python module linked in the accepted answer is not available,
zipfile
module might help对于 ZIP 文件,有一个命令 zipinfo。
For the ZIP files, there is a command zipinfo.
类型很简单,只需查看文件头(
PK
和Rar
)。至于其余的,我怀疑压缩内容中是否有可用的信息。
The type is easy, just look at the file headers (
PK
andRar
).As for the rest, I doubt that information is available in the compressed content.