Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zip deflated 0% ? Why no compression? [closed]

I'm trying to zip the content of a folder that contains 4 big files, very, very similar. So I expect the size to be reduced.

Here's the command I'm using on linux/fedora:

zip -9 myarchive.zip -r myfolder -P mypassword

I get the response:

adding: myfolder/ (stored 0%)
adding: myfolder/Program1.exe (deflated 0%)
adding: myfolder/Program2.exe (deflated 0%)
adding: myfolder/Program3.exe (deflated 0%)
adding: myfolder/Program4.exe (deflated 0%)

Then I get the archive, which is approx the same size as my original folder.

It seems that no compression is occurring at all. Why?

like image 866
John Smith Optional Avatar asked Nov 09 '12 13:11

John Smith Optional


People also ask

Why are my ZIP files not compressed?

Again, if you create Zip files and see files that cannot be significantly compressed, it is probably because they already contain compressed data or they are encrypted. If you would like to share a file or some files that do not compress well, you might: Email photos by zipping and resizing them.

What does stored 0% mean zip?

So, to answer to your question : the stored 0% is fine ! The file has been added but not compressed.

Are ZIP files always compressed?

zip is just a container-format, which can hold many possible types of compressed and uncompressed entries. Often files are deflated , which means, they are compressed. Others are simply stored , which means they are uncompressed.

What is zip compression level?

The Zip compression level used in current OpenEXR is level 6, marked with the triangle shape point on the graph. Compression ratio is not affected much by the level settings - fastest level (1) compresses data 2.344x; slowest (9) compresses at 2.473x. Levels don't affect decompression performance much.


3 Answers

Unlike tar + gzip, zip uses a new compression table for each file, so even if the four files were identical, it would try to compress each individually.

Technically, tar also sees each file but it strings them together into one long input for gzip, so the compression step works on one huge input which is why tar + gzip usually yields a smaller result than zip.

The question is why your exe files can't be compressed. exe files usually contains large amounts of easily compressible data, so they should shrink ("deflate") by at least 30%. Maybe the files are encrypted or obfuscated; these processes make the result hard to compress.

like image 153
Aaron Digulla Avatar answered Oct 12 '22 00:10

Aaron Digulla


Deflated 0% means that it did try to compress, but got effectively no compression. As noted, the zip format cannot take advantage of similarity between different entries. tar + gzip can, but even then only if the similarities end up less than 32K bytes away from each other. Other formats can exploit longer distance similarities, such as xz.

It is normal for uncompressed executables to compress by 30% to 50%, which means that your executables are either a) compressed by something like UPX, b) they are self-extracting compressed data, where the decompressor is stored ahead of the compressed data, c) they are very short executables with a lot of compressed data, or d) they are mostly encrypted.

like image 28
Mark Adler Avatar answered Oct 12 '22 00:10

Mark Adler


Aaron is correct. According to Wikipedia, the ZIP format compresses before it archives, so similarities among different files doesn't help compression.

Are you really trying to compress .exe files? Somehow I doubt that's your actual file type.

See http://en.wikipedia.org/wiki/ZIP_(file_format)#Advantages_and_disadvantages .

like image 3
James Avatar answered Oct 12 '22 01:10

James