MiniRaw
A layered file format for raw photos: a compact working copy whose error at every pixel is bounded by a noise model measured from the image, an optional layer that restores every sensor value bit for bit, and a built-in search thumbnail. Release v2.1, file format version 2 (the v1.0 README is archived in docs/readme_v1.md).
A raw photo is mostly noise, and noise doesn't compress. MiniRaw measures each image's noise, keeps the part of every value that rises above it in a hot tier, and moves the rest into a cold layer that can live on cheaper storage or be dropped.
| Part | Contents | Tier |
|---|---|---|
| Header (L0) | Sensor metadata, noise model, quantization tables, technical statistics, optional search embedding | Hot |
| IDX | A 512 px index thumbnail (JPEG XL, about 34 KB) | Hot |
| L2 signal | Every sensor value, quantized to a fraction of the noise at its brightness, in 512 px tiles | Hot |
| L3 noise | Each value's exact position inside its quantization bin | Cold |
| Original container and previews | Enough to rebuild the original raw file byte for byte (Sony ARW lossless, lossless DNG) | Hot / cold |
Decode modes:
index: header only.preview: the thumbnail.signal: every value within the noise bound.exact: bit-exact, verified against the original's SHA-256.
signal and exact also decode a rectangle, reading only the tiles it touches.
Quick start
Needs Python 3.11 or newer and a raw format LibRaw reads (Sony ARW, Nikon NEF, Canon CR2, DNG and most others).
Tested on macOS (Apple silicon), Linux and Windows. On Intel Macs and ARM Linux, pip has to build rawpy or
constriction from source, which needs LibRaw or a Rust toolchain.
python3 -m pip install miniraw # or the latest main: pip install git+https://github.com/Greenere/miniraw
miniraw encode DSC0001.ARW DSC0001.mraw # one photo: prints what was kept and how big each part is
miniraw decode DSC0001.mraw restored.ARW # the original file back, byte for byte
miniraw bundle ~/Photos/trip trip.zip --cold drop # a whole folder, near-lossless raws, smallest
miniraw unbundle trip.zip trip-restored/ # on the other end: ordinary raw files again
Commands never replace an existing file unless given --force. miniraw COMMAND --help lists the options, and
miniraw info FILE.mraw shows what a file holds.
Results
Measured on 60 MIT-Adobe FiveK raw files never used to develop the codec (37 are linear raw, from 14 cameras of 2003-2009; the rest were processed in camera and are checked but not counted in sizes). Medians over images.
| MiniRaw format 2 | |
|---|---|
| Hot tier | 0.37x the camera's raw file, 0.42x JPEG XL lossless |
| Worst pixel in the hot tier | 0.58x the modelled noise (no pixel outside the error bound) |
| Every layer, sensor-exact | 0.88x the camera's file, 0.987x JPEG XL lossless |
| Exact decodes matching the original's hash | 60 of 60 |
| Indexing a file | One 16 KB header read with a stored embedding; about 51 KB to re-index |
The error bound is per pixel, and relative to a model. The step sets the trade-off: in units of the noise MiniRaw estimates at each pixel's brightness, no value moves more than half a step (plus one raw unit). The bound holds against that estimate, which can run high on textured, low-noise images; it is not an independently measured guarantee. Against a fixed square-root curve, the approach of in-camera lossy raw modes, MiniRaw is smaller at the same worst-case error and about equal at the same average error. A calibrated square-root quantizer, the established technique, matches MiniRaw's size and average error (results/p0_benchmark.md):
Search. On 493 more unseen FiveK images, embeddings of the IDX thumbnail match those of a full-resolution
render closely:
- Neighbour overlap@10 is 0.84 under CLIP and 0.86 under SigLIP. The camera's own embedded thumbnail scores 0.67 and 0.69.
- Zero-shot classification is within 1 point of the full render.
- The plan's target of 0.90 overlap is not met; JPEG XL compression of the thumbnail costs about 0.07.
What format 2 changed (against format 1 on the same 60 images): hot tier -1.8%, lossless total -1.2%, and the
reconstruction bias -38% with no bound violations. The format 1 base layer (L1) is gone, because L2 coded better
without it, and IDX replaces it for preview and search. Details: results/v2_benchmark.md.
A modern camera: Sony A7 IV
10 photos from a Sony A7 IV (33 MP, 14-bit, lossless-compressed ARW), medians over the 10 files. These photos were used while developing the codec, so treat them as a tuning set, not held-out evidence.
- Hot tier: 11.6 MB per photo, 72% smaller than the 41.2 MB ARW, including the 33 KB index thumbnail. The median worst pixel is 0.69x the modelled noise at that brightness, and no pixel leaves the bound. The per-decile bias check passes on this camera (0.017 against a 0.02 limit).
- Every layer: 27.6 MB, sensor-exact, 33% smaller than the ARW and 2.5% smaller than JPEG XL lossless (28.3 MB).
- File-exact: 30.3 MB, 26% smaller than the ARW. This restores the original ARW byte for byte, verified on all 10 files. It adds the ARW's container (0.18 MB, hot) and embedded previews (3.0 MB, cold, losslessly repacked).
- Against format 1 on the same files: hot tier -1.2%, every layer -0.7%, file-exact 30.9 to 30.3 MB.
Size against error. Error is in units of the noise model's sigma at each pixel's brightness, estimated from the image, so 1 sigma is roughly "as large as the noise already in the photo".
- Worst-case error is where MiniRaw differs from a fixed curve. It fits the noise for each sensor and brightness.
A calibrated curve closes most of this gap; see results/p0_benchmark.md.
On these files:
- At 9.4 MB (step 1.5), no pixel errs by more than 0.92 sigma.
- At a similar 10.8 MB, a fixed square-root curve reaches 5.0 sigma, in the shadows and highlights where the curve doesn't match the sensor.
- JPEG XL lossy reaches 10.8 sigma at 12.6 MB. It is tuned for how displayed images look, not for raw data that will be pushed and graded.
- Average error is about 20% lower than the square-root curve's at the same size (17-22% from 9 to 15 MB). Most of the saving comes from not storing noise; calibration mainly adds a guarantee for every pixel.
Encode speed.
- Lossless.
- At effort 7, MiniRaw is smaller and slightly faster than JPEG XL lossless: 27.6 MB in 1.4 s against 28.3 MB in 1.5 s.
- At the default effort 4 it takes 0.82 s for 28.0 MB.
- JPEG-LS is the fastest lossless option (0.07 s) and about 4% larger.
- Near-lossless. MiniRaw's hot tier encodes in 0.72 s (effort 4) and keeps every pixel within the sensor noise. The lossy methods reach similar or smaller sizes in about 1 s, but their worst pixels are 5-13x the noise.
- Timing. Apple M4 Pro, from sensor data already in memory, so reading the file and decoding the raw are excluded. Tiled codecs encode the four Bayer planes in 512-pixel tiles on 8 threads, as MiniRaw does. ZIP is single-threaded, as zip tools are.
Data: results/per_image/personal_raws_v2_d31/ (charts; current code, D31), results/experiments/speed_personal_raws_v2.csv and
file_exact_personal_raws_v2.csv. The format 1 charts for the same files are in
docs/readme_v1.md.
Limitations.
- 2x2 Bayer sensors only.
- Byte-exact restore of the original file only for lossless-JPEG-tiled raws; everything else restores as DNG with bit-exact sensor data.
- The held-out cameras are 2003-2009 models.
- The error bound is relative to MiniRaw's own noise estimate, not to independently measured sensor noise.
- A calibrated square-root quantizer is 0.1-0.5% smaller at the same step and equal in average error; MiniRaw's measured advantages over it are lower bias and the layered format.
- The spec's per-decile bias check (0.02σ) still fails on real images.
- The noise estimate can run high on textured, low-noise images.
Details in docs/METHOD.md.
Setup for development
python3 -m venv .venv && .venv/bin/pip install -e '.[dev]' # dev adds pytest, matplotlib and pandas (benchmarks)
.venv/bin/pip install -e '.[index]' # optional: search embeddings (OpenCLIP, PyTorch)
.venv/bin/python -m pytest
CLI
miniraw encode IN.ARW OUT.mraw [--step 1.0] [--effort 4] [--no-l3] [--no-original] [--threads N]
miniraw encode IN.ARW OUT.mraw --embed # also store a CLIP embedding of the thumbnail (needs [index])
miniraw encode IN.ARW OUT.mraw --format-version 1 # a file MiniRaw v1.0 readers decode
# decode: the output type follows the extension
miniraw decode IN.mraw OUT.ARW # the original raw file: byte for byte with L3, near-lossless without
miniraw decode IN.mraw OUT.dng # raw again: bit-exact sensor data (verified), lossless-JPEG DNG
miniraw decode IN.mraw OUT.jpg # developed with LibRaw, camera white balance, EXIF kept
miniraw decode IN.mraw OUT.png --bits 16 # also .tif; --exposure EV, --half-size, --no-auto-bright
miniraw decode IN.mraw thumb.jpg --mode preview # the stored 512 px thumbnail
miniraw decode IN.mraw crop.jpg --region x,y,w,h # reads only the touched tiles
miniraw decode IN.mraw OUT.npy | OUT.json # raw mosaic array | header
miniraw info IN.mraw # sizes, noise model, technical statistics, thumbnail, embeddings
miniraw strip IN.mraw # drop the cold layer in place
miniraw split IN.mraw # move it to IN.mraw.l3 (decode with --sidecar IN.mraw.l3)
- Default decode modes.
.dngand.npygetexactwhen L3 is present; images getsignal, which looks identical and is about twice as fast. - The DNG carries the colour matrix, white balance, black and white levels, default crop, orientation and capture EXIF.
- Old files. Files written by MiniRaw v1.0 decode exactly as before.
Restoring the original file. When the sensor data is stored as lossless-JPEG tiles (Sony ARW lossless, lossless
DNG), encode keeps the file's TIFF structure and maker notes (hot, about 0.2-0.4 MB) and its embedded previews
(cold, repacked losslessly). Decoding to the original extension then returns the identical file, checked against
its SHA-256. Without the cold layer, it returns a valid file in the same format holding the near-lossless pixels.
Other raw formats decode to DNG; --no-original skips this.
Bundle a whole folder
miniraw bundle ~/Photos/2026-09-Alaska trip.zip # everything restorable exactly
miniraw bundle ~/Photos/2026-09-Alaska trip.zip --cold split # trip.zip (hot) + trip.l3.zip (cold)
miniraw bundle ~/Photos/2026-09-Alaska trip.zip --cold drop # near-lossless raws only, smallest (= --no-l3)
miniraw unbundle trip.zip restored/
miniraw unbundle trip.zip previews/ --raw-as jpg
miniraw unbundle trip.zip --list
| In the folder | In the bundle | Restored as |
|---|---|---|
| Raw files (2x2 Bayer) | .mraw |
The identical file where supported, otherwise DNG with bit-exact sensor data (--raw-as for other forms) |
| JPEG | Lossless JPEG XL repack, about 21% smaller | The identical JPEG |
| PNG | Stored; or lossless JPEG XL with --png repack, about 42% smaller |
Identical bytes; or identical pixels |
| Anything else | Stored as-is | The identical file |
A manifest.json records every file's path, size, SHA-256 and modification time, and unbundle verifies each
restored file. JPEGs and PNGs are repacked, not MiniRaw-coded: after demosaicing, tone curves and rounding to 8 bits
there is no sensor noise left to drop.
Try it on your own raw file
python -m bench.eval PATH/TO/IMG.NEF # sizes, checks, step sweep, square-root comparison
python -m bench.eval IMG.CR2 --render out/ --out IMG.mraw # + render comparison crops, keep the .mraw
Any 2x2-Bayer raw that LibRaw opens works. Use the camera's lossless or uncompressed raw mode: lossy raw modes have already discarded data, and the script warns when it detects that.
Benchmarks and documents
| Document | What it covers |
|---|---|
| results/v2_benchmark.md | Format 2 against format 1 on fresh images; index results |
| results/p0_benchmark.md | MiniRaw against calibrated companding and a predictor-matched JPEG XL; D31 verification |
| results/fivek_benchmark.md | Held-out FiveK benchmark of format 1, and the noise-model failures it found |
| results/index_benchmark.md | Whether the base layer can serve as a search index (it couldn't) |
| docs/METHOD.md | How MiniRaw works, with the evidence for each part |
| docs/v2_advancement.md | Plan for further compression and indexability |
| results/DEVIATIONS.md | Every departure from SPEC.md, numbered |
| CHANGELOG.md | Changes by release |
python -m bench.datasets --split dev # 20 FiveK DNGs (about 200 MB)
python -m bench.run --config configs/v2.toml --split dev --name dev_v2
python -m bench.report --split dev_v2 --out results/report_dev_v2.md
Splits: dev, test, holdout, holdout2 (60 images each except dev), and index500, index500b for the index
benchmark. configs/phase1.toml is format 1, configs/v2.toml format 2.
Layout
src/miniraw/ io_raw, noise, vst, layers, entropy, container, codec, index, stats, source, export, bundle, cli
baselines/ b1_native (camera file), b2_jxl (JPEG XL lossless), b5_sqrt (square-root curve)
bench/ datasets, synth, metrics, run, report, splits/, experiments/
tests/ acceptance and regression tests (tests/data: a file written by v1.0.0)
results/ generated reports and per-image data (DEVIATIONS.md is written by hand)
docs/ method, plans, archived v1.0 README, chart images
Metadata
Release files for miniraw 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| miniraw-2.1.0.tar.gz | 61.3 kB | With provenance | Details for miniraw-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| miniraw-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for miniraw-2.1.0-py3-none-any.whl |
Total release size: 121.6 kB
Release files / miniraw-2.1.0.tar.gz
| Download URL | miniraw-2.1.0.tar.gz |
|---|---|
| Size | 61.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4936ac86552e320c4072cd83a6cdee0cafe8801d411bf3b1e4c4a6abafa4ddd1
|
|
BLAKE2b-256 checksum How to use checksums |
42cf61ce97aabf8abca4774028e84f097c26ee28d4030173d347542ace7ef80e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / miniraw-2.1.0-py3-none-any.whl
| Download URL | miniraw-2.1.0-py3-none-any.whl |
|---|---|
| Size | 60.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e04df7a39b2acb48724cd39b9d6931f1f89aa2af54544c79ce015ba9d8bde3c
|
|
BLAKE2b-256 checksum How to use checksums |
38006739054bd130cd705d83d6476024e0e35207a91078914fc92e89232e64a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logSecurity for miniraw 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for miniraw-2.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.