zipbrotli

What is the id number for Brotli compression inside a ZIP archive?


The ZIP file format supports a number of compression algorithms and assigns them numbers, for example 0 is store, 8 is deflate, and 14 is lzma. What number indicates Brotli compression? Is there any additional zip-level metadata needed for this compression algorithm?


Solution

  • As of this writing, there isn't one. The official list of ZIP file format compression methods is found in PKWare's ZIP Appnote, for which the most recent version is 6.3.4, dated October 1, 2014. Here are the defined compression methods therein:

       4.4.5 compression method: (2 bytes)
    
            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
    

    I suppose you could define your own method number and use it, but that use would be non-standard. (It is a two-byte field, so you could pick a large number that PKWare would be very unlikely to define to be something else.)

    No, there is no other information required to be able to decompress a brotli stream.

    Update:

    As of the July 2020 appnote (6.3.9), more compression methods, notably zstd and xz, but still no brotli.

       4.4.5 compression method: (2 bytes)
    
            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
           15 - Reserved by PKWARE
           16 - IBM z/OS CMPSC Compression
           17 - Reserved by PKWARE
           18 - File is compressed using IBM TERSE (new)
           19 - IBM LZ77 z Architecture 
           20 - deprecated (use method 93 for zstd)
           93 - Zstandard (zstd) Compression 
           94 - MP3 Compression 
           95 - XZ Compression 
           96 - JPEG variant
           97 - WavPack compressed data
           98 - PPMd version I, Rev 1
           99 - AE-x encryption marker (see APPENDIX E)