xref: /aosp_15_r20/external/cronet/third_party/brotli/tools/brotli.md (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1brotli(1) -- brotli, unbrotli - compress or decompress files
2================================================================
3
4SYNOPSIS
5--------
6
7`brotli` [*OPTION|FILE*]...
8
9`unbrotli` is equivalent to `brotli --decompress`
10
11DESCRIPTION
12-----------
13`brotli` is a generic-purpose lossless compression algorithm that compresses
14data using a combination of a modern variant of the **LZ77** algorithm, Huffman
15coding and 2-nd order context modeling, with a compression ratio comparable to
16the best currently available general-purpose compression methods. It is similar
17in speed with deflate but offers more dense compression.
18
19`brotli` command line syntax similar to `gzip (1)` and `zstd (1)`.
20Unlike `gzip (1)`, source files are preserved by default. It is possible to
21remove them after processing by using the `--rm` _option_.
22
23Arguments that look like "`--name`" or "`--name=value`" are _options_. Every
24_option_ has a short form "`-x`" or "`-x value`". Multiple short form _options_
25could be coalesced:
26
27* "`--decompress --stdout --suffix=.b`" works the same as
28* "`-d -s -S .b`" and
29* "`-dsS .b`"
30
31`brotli` has 3 operation modes:
32
33* default mode is compression;
34* `--decompress` option activates decompression mode;
35* `--test` option switches to integrity test mode; this option is equivalent to
36  "`--decompress --stdout`" except that the decompressed data is discarded
37  instead of being written to standard output.
38
39Every non-option argument is a _file_ entry. If no _files_ are given or _file_
40is "`-`", `brotli` reads from standard input. All arguments after "`--`" are
41_file_ entries.
42
43Unless `--stdout` or `--output` is specified, _files_ are written to a new file
44whose name is derived from the source _file_ name:
45
46* when compressing, a suffix is appended to the source filename to
47  get the target filename
48* when decompressing, a suffix is removed from the source filename to
49  get the target filename
50
51Default suffix is `.br`, but it could be specified with `--suffix` option.
52
53Conflicting or duplicate _options_ are not allowed.
54
55OPTIONS
56-------
57
58* `-#`:
59    compression level (0-9); bigger values cause denser, but slower compression
60* `-c`, `--stdout`:
61    write on standard output
62* `-d`, `--decompress`:
63    decompress mode
64* `-f`, `--force`:
65    force output file overwrite
66* `-h`, `--help`:
67    display this help and exit
68* `-j`, `--rm`:
69    remove source file(s); `gzip (1)`-like behaviour
70* `-k`, `--keep`:
71    keep source file(s); `zstd (1)`-like behaviour
72* `-n`, `--no-copy-stat`:
73    do not copy source file(s) attributes
74* `-o FILE`, `--output=FILE`
75    output file; valid only if there is a single input entry
76* `-q NUM`, `--quality=NUM`:
77    compression level (0-11); bigger values cause denser, but slower compression
78* `-t`, `--test`:
79    test file integrity mode
80* `-v`, `--verbose`:
81    increase output verbosity
82* `-w NUM`, `--lgwin=NUM`:
83    set LZ77 window size (0, 10-24) (default: 24); window size is
84    `(2**NUM - 16)`; 0 lets compressor decide over the optimal value; bigger
85    windows size improve density; decoder might require up to window size
86    memory to operate
87* `-D FILE`, `--dictionary=FILE`:
88    use FILE as raw (LZ77) dictionary; same dictionary MUST be used both for
89    compression and decompression
90* `-S SUF`, `--suffix=SUF`:
91    output file suffix (default: `.br`)
92* `-V`, `--version`:
93    display version and exit
94* `-Z`, `--best`:
95    use best compression level (default); same as "`-q 11`"
96
97SEE ALSO
98--------
99
100`brotli` file format is defined in
101[RFC 7932](https://www.ietf.org/rfc/rfc7932.txt).
102
103`brotli` is open-sourced under the
104[MIT License](https://opensource.org/licenses/MIT).
105
106Mailing list: https://groups.google.com/forum/#!forum/brotli
107
108BUGS
109----
110Report bugs at: https://github.com/google/brotli/issues
111