Title: | A Compression Format Optimized for the Web |
---|---|
Description: | A lossless compressed data format that uses a combination of the LZ77 algorithm and Huffman coding <https://www.rfc-editor.org/rfc/rfc7932>. Brotli is similar in speed to deflate (gzip) but offers more dense compression. |
Authors: | Jeroen Ooms [aut, cre] , Google, Inc [aut, cph] (Brotli C++ library) |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.1 |
Built: | 2024-12-02 05:59:19 UTC |
Source: | https://github.com/jeroen/brotli |
Brotli is a compression algorithm optimized for the web, in particular small text documents.
brotli_compress(buf, quality = 11, window = 22) brotli_decompress(buf)
brotli_compress(buf, quality = 11, window = 22) brotli_decompress(buf)
buf |
raw vector with data to compress/decompress |
quality |
value between 0 and 11 |
window |
log of window size |
Brotli decompression is at least as fast as for gzip while significantly improving the compression ratio. The price we pay is that compression is much slower than gzip. Brotli is therefore most effective for serving static content such as fonts and html pages.
For binary (non-text) data, the compression ratio of Brotli usually does not beat
bz2
or xz (lzma)
, however decompression for these algorithms is too
slow for browsers in e.g. mobile devices.
J. Alakuijala and Z. Szabadka (July 2016). Brotli Compressed Data Format. IETF Internet Draft https://www.rfc-editor.org/rfc/rfc7932.
# Simple example myfile <- file.path(R.home(), "COPYING") x <- readBin(myfile, raw(), file.info(myfile)$size) y <- brotli_compress(x) stopifnot(identical(x, brotli_decompress(y))) # Compare to other algorithms length(x) length(brotli_compress(x)) length(memCompress(x, "gzip")) length(memCompress(x, "bzip2")) length(memCompress(x, "xz"))
# Simple example myfile <- file.path(R.home(), "COPYING") x <- readBin(myfile, raw(), file.info(myfile)$size) y <- brotli_compress(x) stopifnot(identical(x, brotli_decompress(y))) # Compare to other algorithms length(x) length(brotli_compress(x)) length(memCompress(x, "gzip")) length(memCompress(x, "bzip2")) length(memCompress(x, "xz"))