One of my colleagues tried to use standard GDAL to read our recent mrf-encoded orthofiles and found that it couldn't.
After some investigations he found that the mrf-files have Brunsli-compression and had to make a new build of gdal where this was included.
A couple of questions arise:
- If Brunslicompression is the correct thing to do, why is it not included in GDAL by default?
- If it is not, then why is it used by default by OptimizeRasters?
- How can I force OptimizeRasters to skip the Brunslicompression . A setting in a config-file?
https://github.com/Esri/OptimizeRasters/blob/master/GDAL/bin/brunslidec-c.dll
ChatGPT gave me the summary blow. It confirms that this is limiting the type of clients that can read the files:
- Not suitable where you need a format natively supported by browsers/clients — it’s an extra step (encode/decode) and requires Brunsli support on both ends.
- Adoption is limited — ecosystem/tools are smaller than for JPEG/PNG/WebP/etc.
ChatGPT:
Do you mean the Brunsli JPEG-recompression tool from Google Research? I can explain what it is, how it works at a high level, how to use it, and tradeoffs — or help compress some images if you want. Summary first, then options.
What Brunsli is
Brunsli is a lossless JPEG-recompression format/tool (developed by Google Research) that re-encodes an existing JPEG bitstream into a more compact representation. After decompression you get back the original JPEG bitstream (and therefore the identical decoded image).
It is NOT a new image format for browsers; it’s a way to store/transmit existing JPEGs more efficiently while preserving exact JPEG decoding semantics.
How it works (high level)
It parses the JPEG file (DCT coefficients, quantization tables, metadata, Huffman tables, etc.), removes redundancy in how coefficients and tables are represented, and re-encodes the data using more efficient models and entropy coding than baseline JPEG’s canonical Huffman representation.
The result is a Brunsli blob that can be losslessly converted back to the original JPEG bytes (so any standard JPEG decoder yields the same pixels).
The algorithm uses context modeling tailored to JPEG coefficient statistics (not simply generic gzip/deflate).
Why/when to use it
Good for archival or transmission where you must keep an exact JPEG (or exact pixel output) but want to reduce bytes.
Typical savings depend on image content and existing JPEG encoder; many images see meaningful savings vs. the original JPEG and versus standard compressors (gzip/zlib), although exact numbers vary.
Not suitable where you need a format natively supported by browsers/clients — it’s an extra step (encode/decode) and requires Brunsli support on both ends.
Tradeoffs
Compression is more CPU/time intensive than running a standard lossless compressor; decompression is generally faster but still more work than a simple unzip.
Adoption is limited — ecosystem/tools are smaller than for JPEG/PNG/WebP/etc.
Good when you control both ends (server+client) or when storing images for later retrieval.
Using Brunsli (CLI)
The official source and binaries are on the Google brunsli repo: https://github.com/google/brunsli
Typical usage (examples — check your installed version’s --help/README to confirm exact flags):
Encode (JPEG -> brunsli): brunsli -encode input.jpg output.brunsli
Decode (brunsli -> JPEG): brunsli -decode input.brunsli output.jpg
Most builds include a binary and a library. On Linux/macOS you can build from source with the repo’s instructions (cmake or bazel depending on the version).
Programmatic use
The repo exposes a C++ library you can link into your programs to compress/decompress JPEGs.
There are third-party bindings for some languages (search for “brunsli” + your language). If you need a script, I can provide an example (bash, Python wrapper calling the CLI, or C++ snippet).
Alternatives and comparisons
Compared to general-purpose compressors (gzip, zstd on raw JPEG) Brunsli usually wins because it understands JPEG internals.
It’s conceptually different from re-encoding the image using a different lossy encoder (e.g., WebP/AVIF/MozJPEG) — those change the image pixels or quantization and may produce smaller files but are lossy or require consumers to support the new format.
For aggressive byte-size reduction with acceptable visual changes, re-encoding to modern image formats (AVIF/WebP) is often better for web delivery; use Brunsli when the JPEG must be preserved.
One of my colleagues tried to use standard GDAL to read our recent mrf-encoded orthofiles and found that it couldn't.
After some investigations he found that the mrf-files have Brunsli-compression and had to make a new build of gdal where this was included.
A couple of questions arise:
https://github.com/Esri/OptimizeRasters/blob/master/GDAL/bin/brunslidec-c.dll
ChatGPT gave me the summary blow. It confirms that this is limiting the type of clients that can read the files:
ChatGPT:
Do you mean the Brunsli JPEG-recompression tool from Google Research? I can explain what it is, how it works at a high level, how to use it, and tradeoffs — or help compress some images if you want. Summary first, then options.
What Brunsli is
Brunsli is a lossless JPEG-recompression format/tool (developed by Google Research) that re-encodes an existing JPEG bitstream into a more compact representation. After decompression you get back the original JPEG bitstream (and therefore the identical decoded image).
It is NOT a new image format for browsers; it’s a way to store/transmit existing JPEGs more efficiently while preserving exact JPEG decoding semantics.
How it works (high level)
It parses the JPEG file (DCT coefficients, quantization tables, metadata, Huffman tables, etc.), removes redundancy in how coefficients and tables are represented, and re-encodes the data using more efficient models and entropy coding than baseline JPEG’s canonical Huffman representation.
The result is a Brunsli blob that can be losslessly converted back to the original JPEG bytes (so any standard JPEG decoder yields the same pixels).
The algorithm uses context modeling tailored to JPEG coefficient statistics (not simply generic gzip/deflate).
Why/when to use it
Good for archival or transmission where you must keep an exact JPEG (or exact pixel output) but want to reduce bytes.
Typical savings depend on image content and existing JPEG encoder; many images see meaningful savings vs. the original JPEG and versus standard compressors (gzip/zlib), although exact numbers vary.
Not suitable where you need a format natively supported by browsers/clients — it’s an extra step (encode/decode) and requires Brunsli support on both ends.
Tradeoffs
Compression is more CPU/time intensive than running a standard lossless compressor; decompression is generally faster but still more work than a simple unzip.
Adoption is limited — ecosystem/tools are smaller than for JPEG/PNG/WebP/etc.
Good when you control both ends (server+client) or when storing images for later retrieval.
Using Brunsli (CLI)
The official source and binaries are on the Google brunsli repo: https://github.com/google/brunsli
Typical usage (examples — check your installed version’s --help/README to confirm exact flags):
Encode (JPEG -> brunsli): brunsli -encode input.jpg output.brunsli
Decode (brunsli -> JPEG): brunsli -decode input.brunsli output.jpg
Most builds include a binary and a library. On Linux/macOS you can build from source with the repo’s instructions (cmake or bazel depending on the version).
Programmatic use
The repo exposes a C++ library you can link into your programs to compress/decompress JPEGs.
There are third-party bindings for some languages (search for “brunsli” + your language). If you need a script, I can provide an example (bash, Python wrapper calling the CLI, or C++ snippet).
Alternatives and comparisons
Compared to general-purpose compressors (gzip, zstd on raw JPEG) Brunsli usually wins because it understands JPEG internals.
It’s conceptually different from re-encoding the image using a different lossy encoder (e.g., WebP/AVIF/MozJPEG) — those change the image pixels or quantization and may produce smaller files but are lossy or require consumers to support the new format.
For aggressive byte-size reduction with acceptable visual changes, re-encoding to modern image formats (AVIF/WebP) is often better for web delivery; use Brunsli when the JPEG must be preserved.