flashraw README

The project's README from github.com/ybouane/flashraw. As one markdown file: README.md.

Built by @ybouane · see also LightFlow · ImageFlow

FlashRaw

FlashRaw: the fast, safe camera RAW decoder

The fast, safe camera RAW decoder. ▶ Live demo: open a RAW file right in your browser.

Rust core · C, C++, Python and JavaScript bindings · SIMD, all cores and the GPU · runs in the browser

Version 0.6.0 is published on crates.io, PyPI and npm. See docs/packages.md for every package and its install command.

crates.io docs.rs npm PyPI License: MIT OR Apache-2.0 MSRV 1.85

FlashRaw opens a camera RAW file and gives you the sensor data plus everything needed to interpret it (CFA layout, black and white levels, white balance, colour matrices, crops, orientation), the embedded previews, or a display-ready sRGB image. It is written in memory-safe Rust. Of the 2,016 files in the raw.pixls.us corpus, 2,008 decode (99.6%), and 1,993 of them have pinned output hashes; the other 8 are formats it does not support yet or files that are not RAW (Light L16, Casio CAM, JPEG-in-DNG, a few more: docs/formats.md). On the same machine as the other open-source decoders it is 12.6×–19.2× faster than LibRaw at decoding, 11.8×–22.1× faster at producing an sRGB image, and needs 1.5×–1.8× less memory for it (medians over 62 popular cameras).

⚡ FlashRaw vs the others

Median over the 62 bodies, phones and drones of benches/popular-cameras.tsv, each library on the files it can decode, same files, same machine, all cores. N× faster = the other library's time ÷ FlashRaw's; N× less memory = the other library's peak memory ÷ FlashRaw's.

FlashRaw compared with 🐧 Linux · Ryzen 7 9700X 🍎 macOS · Apple M1 Ultra
Decode (RAW → 16-bit sensor data)
vs LibRaw unpack() 12.6× faster 19.2× faster
vs RawSpeed (darktable) 2.7× faster 2.0× faster
vs rawler (dnglab, Rust) 3.2× faster 2.9× faster
vs rawpy (Python) 15.3× faster 21.1× faster
vs dcraw (single-threaded) 19.0× faster 35.2× faster
RAW → sRGB image (demosaic, white balance, colour, 8-bit sRGB)
vs LibRaw dcraw_process() 11.8× faster · 1.8× less memory 22.1× faster · 1.5× less memory
vs LibRaw + Little CMS (linear ProPhoto → sRGB) 20.8× faster · 2.7× less memory 29.4× faster · 2.2× less memory
vs rawler RawDevelop 9.0× faster · 4.1× less memory 7.2× faster · 4.5× less memory
vs rawpy postprocess() 13.2× faster · 1.9× less memory 25.2× faster · 1.6× less memory
vs dcraw (single-threaded) 12.5× faster · 1.3× less memory 27.9× faster · about the same memory
⚡ FlashRaw GPU (Metal) vs LibRaw dcraw_process() – 25.3× faster

Builds favour the others where possible (LibRaw and RawSpeed with OpenMP and -O3, -march=native on x86-64; the Little CMS transform on all cores; dcraw has no threads). Every number, the method, per-camera and per-format tables, one-thread results, and the cases where FlashRaw is not the fastest (RawSpeed on some uncompressed and Sony lossless files; LibRaw on some Canon CR3 and small uncompressed files, rawler on the JPEG XL DNG) and uses more memory (a plain decode on all cores: FlashRaw's parallel decoders keep per-thread buffers) are in docs/benchmarks.md. Reproduce with tools/bench/compare.py.

Bar chart: RAW decode time of LibRaw, rawpy, dcraw, rawler and RawSpeed relative to FlashRaw, median over 62 popular cameras, on Linux and macOS

Bar chart: time from RAW file to an 8-bit sRGB image for LibRaw + Little CMS, LibRaw, rawpy, dcraw and rawler relative to FlashRaw (CPU and GPU), median over 62 popular cameras

🧠 Memory

Bar chart: peak memory of each library relative to FlashRaw, for RAW to sRGB and for decoding only

To produce an sRGB image FlashRaw develops in one fused pass (demosaic, white balance, colour matrix and sRGB encoding per pixel, straight into the output), so it never holds the full-size intermediate images of a classic pipeline: LibRaw keeps a 4-channel 16-bit working image, the LibRaw + Little CMS pipeline adds a 16-bit RGB copy and the 8-bit output, rawler develops in 32-bit floats. Decoding alone needs about the same memory everywhere (the file plus a 16-bit image); with all cores FlashRaw's speculative parallel decoders add per-thread buffers, so a plain all-core decode can take more memory than LibRaw's (details in docs/benchmarks.md).

📷 Per camera

Dot plot: decode and RAW to RGB time in milliseconds for 12 popular cameras, FlashRaw, LibRaw, RawSpeed and rawler, Apple M1 Ultra

🏭 Used in production

LightFlow Professional photo correction and colour grading, running locally in your browser with WebGPU
ImageFlow A Photoshop-class image editor in your browser

Both open camera RAW files with FlashRaw's WebAssembly package, right in the browser.

✨ Why FlashRaw

⚡ Speed

  • Multithreaded decoding wherever the format allows it, including single-stream codecs (lossless JPEG, Nikon, Pentax, Hasselblad, Panasonic v8, Sony ARW1) through speculative parallel decoding; a few strictly sequential codecs (for example Samsung V2) decode on one thread
  • SIMD unpack kernels for packed data (SSSE3/SSE4.1 on x86-64, NEON on aarch64, WASM SIMD128), picked at run time; the rest of the pipeline relies on the compiler's auto-vectorisation
  • 64-bit bit pumps, table-driven Huffman, zero-copy parsing, memory-mapped input
  • Fused single-pass RAW → RGB, on the CPU or the GPU, in sRGB, Display P3, Adobe RGB, ProPhoto or Rec. 2020 at no extra per-pixel cost (ICC-tagged, any ICC profile via icc)
  • Region and tile decodes, zero-copy embedded previews: no full decode when you don't need one

🛡️ Security

  • Memory-safe Rust: parsers that read untrusted files cannot overflow buffers or use freed memory; the few unsafe blocks are audited and justified
  • Bounds-checked parsing, checked offset arithmetic, IFD loop and depth tracking
  • Allocation limits checked before allocating
  • 15 fuzz targets, run locally before releases; crash inputs replayed forever
  • Malformed-file and truncation suites, and an explicit truncation policy: never silent garbage

📷 Support

  • ~40 RAW formats: 2,008 of the 2,016 raw.pixls.us corpus files decode (99.6%), 1,993 with pinned output hashes; the other 8 are formats not supported yet (Light L16, Casio CAM, JPEG-in-DNG, a few more)
  • CR3 incl. C-RAW, JPEG XL DNG, lossy and deflate DNG, GoPro GPR, Sigma X3F, Fuji compressed, Panasonic v4–v8, IIQ, 3FR/FFF, …
  • GPU: Metal, Vulkan, DX12 and WebGPU
  • Everywhere: Rust, C, C++, Python, npm (browsers, Web Workers, Node)
  • Tested on Linux x86-64 and macOS arm64; WebAssembly in browsers and Node.js; Windows and other architectures are not regularly tested

🆚 Feature comparison

⚡ FlashRaw LibRaw RawSpeed rawler / dnglab dcraw rawpy Little CMS ¹
What it is RAW decoder + developer RAW decoder + developer RAW decoder (darktable) RAW decoder + DNG converter RAW converter program Python binding of LibRaw colour-management engine
Written in 🦀 Rust C++ C++ 🦀 Rust C Python + C++ (LibRaw) C
Memory-safe ✅ (a few audited unsafe blocks) ❌ ❌ ⚠️ Rust, but it panics on bad input and advises against untrusted files ❌ ❌ ❌
Uses the GPU ✅ Metal, Vulkan, DX12, WebGPU ❌ ❌ ❌ ❌ ❌ ❌
Multithreading ✅ wherever the format allows (speculative decoding of sequential streams) + develop ⚠️ OpenMP builds: CR3, Fuji, Panasonic v8, some demosaics ⚠️ OpenMP: tiled/sliced codecs ✅ rayon: tiles, several codecs, develop ❌ ⚠️ as LibRaw; wheels: OpenMP on Linux/Windows, not macOS ⚠️ one thread per transform (threaded plugin: GPL-3 or commercial)
SIMD kernels ⚠️ packed-bit unpack only: SSSE3/SSE4.1, NEON, WASM SIMD128 ❌ ⚠️ one SSE2 routine ⚠️ compiler multiversioning, no intrinsics ❌ ❌ ⚠️ SSE2 in the fast_float plugin (GPL-3 or commercial)
Cameras 2,008 of the 2,016 raw.pixls.us corpus files decode (99.6%), 1,600+ entries in its camera DB, any DNG 1,284 (its own count) ~920 make/model ~850 make/model ~570 colour profiles (last release 2018) as LibRaw –
Canon CR3 (incl. C-RAW) ✅ ✅ ❌ ✅ ❌ ✅ –
JPEG XL DNG (DNG 1.7, e.g. Samsung Galaxy) ✅ ⚠️ Adobe DNG SDK builds only ❌ ✅ ❌ ❌ –
GoPro GPR (VC-5) ✅ ⚠️ GPR SDK builds only ✅ ❌ ❌ ❌ –
DNG opcode lists ✅ all radiometric opcodes, per stage ⚠️ Adobe DNG SDK builds only ⚠️ stage-1 subset ❌ ⚠️ one opcode (lossy DNG) ⚠️ as LibRaw –
RAW → sRGB image ✅ one fused pass, CPU or GPU ✅ dcraw_process(), many demosaics ❌ raw data only ✅ RawDevelop ✅ ✅ postprocess() ⚠️ converts colours, does not decode RAW
ICC colour management ✅ built-in spaces (sRGB, P3, Adobe RGB, ProPhoto, Rec. 2020) + embedded profiles; any ICC v2/v4 profile via the icc feature ⚠️ with Little CMS compiled in ❌ ❌ ⚠️ with Little CMS ⚠️ as LibRaw (Little CMS in the wheels) ✅ ICC v2/v4
Embedded previews ✅ zero-copy ✅ copied ❌ ⚠️ some formats, decoded ✅ -e ✅ extract_thumb() –
Region / tile decode ✅ ❌ ❌ ❌ ❌ ❌ –
C / C++ API ✅ flashraw.h, flashraw.hpp ✅ ⚠️ C++ only ❌ Rust only ❌ command line only ❌ ✅ C
Python ✅ official, NumPy zero-copy, releases the GIL ⚠️ third-party (rawpy) ❌ ❌ ❌ ✅ ⚠️ third-party
JavaScript / WASM, runs in the browser ✅ official npm package (WASM SIMD, threads, WebGPU) ⚠️ third-party ports ❌ ❌ ⚠️ third-party ports ❌ ⚠️ third-party ports
Rust ✅ native ⚠️ third-party bindings ❌ ✅ native ❌ ❌ ⚠️ third-party crate
LibRaw-compatible C API ✅ subset (recompile and relink) – ❌ ❌ ❌ – –
Fuzzed ✅ 11 in-tree targets, run locally before releases ✅ OSS-Fuzz ✅ OSS-Fuzz + in-tree ⚠️ 8 in-tree targets ❌ ⚠️ relies on LibRaw ✅ OSS-Fuzz + in-tree
License MIT / Apache-2.0 LGPL-2.1 / CDDL-1.0 LGPL-2.1+ LGPL-2.1 own licence (Foveon code: GPL-2+) MIT (bundles LibRaw) MIT

¹ Little CMS is not a RAW decoder: it is compared as the colour-management stage of a typical LibRaw-based pipeline (see the benchmarks above). Checked against the sources and docs of LibRaw 0.22, RawSpeed (develop, c835b05), rawler 0.8.0, dcraw 9.28, rawpy 0.27.1 and Little CMS 2.19.1 (October 2026). Camera counts are not directly comparable: LibRaw counts its own way, the RawSpeed and rawler figures are unique make/model pairs in their camera lists, dcraw's is the size of its colour table.

Milliseconds per file on an Apple M1 Ultra (20 cores, macOS), all cores, median of 7 runs, lower is better, bold = fastest. Decode = open + full sensor decode to 16-bit samples. RAW → sRGB = decode + demosaic + white balance + colour conversion to an 8-bit sRGB image (RawSpeed has no RGB pipeline; LibRaw + Little CMS develops to linear ProPhoto RGB and converts it with Little CMS). ❌ = not supported.

Camera Format · codec MP Decode
FlashRaw
LibRaw RawSpeed rawler RAW → sRGB
FlashRaw
LibRaw LibRaw +
Little CMS
rawler
Canon EOS R5 (RAW) CR3 · canon-crx 47 77.5 134 ❌ 246 101 732 1107 507
Canon EOS R6 Mark II (RAW) CR3 · canon-crx 26 44.2 75.6 ❌ 133 57.7 406 609 279
Canon EOS 5D Mark IV (RAW) CR2 · lossless-jpeg 31 20.0 435 111 256 36.3 844 1101 436
Nikon Z8 (14-bit lossless) NEF · nikon-huffman 46 25.7 544 220 361 50.1 1156 1549 630
Nikon Z6III (lossless) NEF · nikon-huffman 24 14.7 282 109 190 27.8 616 823 330
Nikon D850 (14-bit lossless) NEF · nikon-huffman 46 23.7 481 168 323 48.1 1097 1469 584
Sony A7 IV (lossless) ARW · sony-lossless 37 19.0 426 12.3 39.3 36.0 867 1142 223
Sony A7 IV (compressed) ARW · sony-arw2 33 4.21 87.7 8.02 8.39 21.9 530 803 195
Sony A7R V (lossless) ARW · sony-lossless 65 31.0 775 22.1 62.6 62.4 1587 2084 396
Sony A1 (compressed) ARW · sony-arw2 50 6.10 130 11.6 11.8 32.0 804 1209 285
Fujifilm X-T5 (lossless compressed) RAF · fuji-compressed 41 33.3 149 44.2 93.7 66.1 692 1018 392
Fujifilm X-H2 (compressed) RAF · fuji-compressed 41 44.4 174 ❌ 128 90.0 882 1194 423
Fujifilm GFX100 II (lossless compressed) RAF · fuji-compressed 103 61.8 269 78.8 143 116 1601 2437 686
Panasonic Lumix S5II RW2 · panasonic-v8 24 12.1 131 61.2 121 25.1 501 697 229
Panasonic Lumix GH6 RW2 · panasonic-v8 25 12.4 132 62.3 120 26.5 514 721 231
OM System OM-1 Mark II ORF · olympus 20 107 385 162 227 117 671 841 344
Pentax K-3 Mark III PEF · pentax-huffman 27 14.5 200 85.9 176 28.8 559 772 323
Ricoh GR III DNG · lossless-jpeg 25 13.1 323 99.8 215 26.6 653 853 353
Leica Q2 DNG · uncompressed 47 3.90 293 49.5 4.40 28.4 924 1304 261
Leica M10-R DNG · lossless-jpeg 41 20.6 559 202 387 43.9 1114 1461 604
Hasselblad X2D 100C (compressed) FFF · hasselblad 105 65.4 1010 454 ❌ 121 2369 3190 ❌
Phase One IQ4 150MP (IIQ L) IIQ · phaseone 154 40.4 1032 ❌ 341 117 4464 5674 977
Sigma fp L DNG · lossless-jpeg 60 18.1 761 25.4 41.0 57.5 1558 2075 374
Apple iPhone 12 Pro (ProRAW) DNG · lossless-jpeg 12 18.6 464 ❌ 28.1 27.0 595 670 74.7
Google Pixel 8 Pro DNG · lossless-jpeg 50 14.9 656 16.6 34.0 45.9 1477 1884 310
Samsung Galaxy S23 Ultra DNG · lossless-jpeg 50 151 1899 581 1141 194 2191 2480 1305
Samsung Galaxy S22 (JPEG XL) DNG · jpeg-xl 12 285 ❌ ❌ 179 296 ❌ ❌ 222
DJI Phantom 4 Pro DNG · uncompressed 20 1.13 17.7 1.06 1.43 19.0 291 463 116
GoPro HERO11 Black (GPR) DNG · gopro-vc5 27 17.5 ❌ 23.8 ❌ 35.7 ❌ ❌ ❌

The full list (62 bodies, phones, drones and action cameras), the same tables on Linux x86-64, rawpy and dcraw, single-thread results, GPU timings, peak memory per camera and per-format results are in docs/benchmarks.md. Reproduce everything with tools/bench/compare.py; the charts come from tools/bench/charts.py and their numbers are in docs/charts/data.json.

🛡️ Security

RAW files are untrusted input: they come from the web, from email, from memory cards. FlashRaw is built for that.

📷 Supported formats, cameras and platforms

Formats DNG (uncompressed, lossless JPEG, deflate int/float, lossy JPEG, JPEG XL, GoPro VC-5, Blackmagic), CR2 (incl. sRAW/mRAW), CR3 (CRX and C-RAW), CRW, NEF/NRW, ARW/SR2/SRF/ARQ, RAF (incl. compressed X-Trans), RW2/RWL (Panasonic v4–v8), ORF/ORI, PEF, SRW, MRW, IIQ, MOS, 3FR/FFF, KDC/DCR/DCS, ERF, MEF, X3F, ARI, headerless and CHDK raws
Cameras 2,008 of the 2,016 raw.pixls.us corpus files decode (99.6%; 1,993 with pinned hashes), 1,600+ entries in the built-in camera database, and DNG from cameras, phones and drones
Not supported yet 8 corpus files are valid files in formats that are not implemented: Light L16, Casio CAM, JPEG-in-DNG and a few rare variants (see formats). Their metadata and embedded previews still work
Outputs raw u16 / f32, normalised f32, linear RGB f32, display RGBA8 (bilinear, edge-aware, homogeneity-directed, PPG or RCD (Bayer) or half-size demosaic, as-shot white balance, colour matrix, standard tone, sRGB, orientation), GPU-resident textures
GPU wgpu: Metal, Vulkan and DX12 natively, WebGPU in browsers; Backend::Auto uses the GPU only where it measures a win (GPU)
Languages Rust, C, C++, Python, JavaScript/TypeScript, plus a LibRaw-compatible C API
Platforms tested on Linux x86-64 and macOS arm64; WebAssembly in browsers (Chromium, Firefox and WebKit are in the browser test suite), Web Workers and Node.js, multithreaded where the page is cross-origin isolated. Windows and Linux ARM64 are not regularly tested

Support is tracked per format and mode; flashraw supported (and docs/formats.md) lists each with one of these statuses:

Status Meaning
verified representative corpus files decode with full-buffer hashes pinned by the regression suite, metadata checked, tests and corruption handling in place
partial decodes a documented part of the mode (for example only the first frame of a burst or pixel-shift file, or without the vendor's calibration block); the notes say what is missing
experimental implemented from the format structure with few or no sample files, so not covered by pinned hashes
unsupported detected and rejected with a clear error
supported used for a feature rather than a codec mode (currently only DNG opcode lists): implemented, applied by default and covered by tests and fuzzing, with no per-file pinned hash

Platforms

Tested by the maintainer with tools/ci/local.sh and tools/ci/mac.sh (the repository has no automatic GitHub workflows): Linux x86-64 and macOS arm64 (Rust, C, Python, npm, WASM). The workflows in .github/workflows/ define builds for Linux ARM64, macOS x86-64 and Windows (wheels, the C library, the LibRaw shim) but run only on manual dispatch and have not been run regularly; Windows paths are untested. See docs/testing.md.

🚀 Quick start

🦀 Rust

[dependencies]
flashraw = "0.1"
use flashraw::{FlashRaw, DecodeOptions, Backend, OutputFormat};

fn main() -> flashraw::Result<()> {
    let raw = FlashRaw::open_path("photo.NEF")?;          // memory-mapped, headers only

    let m = raw.metadata();
    println!("{} {}x{} ISO {:?}", m.camera(), m.width, m.height, m.exposure.iso);

    // Embedded JPEG preview, zero-copy, without decoding the RAW payload:
    if let Some(p) = raw.preview() {
        std::fs::write("preview.jpg", raw.preview_bytes(p)?)?;
    }

    // Sensor data:
    let frame = raw.decode(DecodeOptions {
        backend: Backend::Auto,
        output: OutputFormat::RawU16,
        ..Default::default()
    })?;
    println!(
        "{}x{} CFA {:?} black {:?} white {:?} via {}",
        frame.width(), frame.height(), frame.cfa, frame.black_level.values,
        frame.white_level.values, frame.stats().backend.decode
    );

    // Display-ready RGBA8 (bilinear demosaic, as-shot WB, colour matrix, sRGB, orientation):
    let rgba = raw.decode(DecodeOptions { output: OutputFormat::Rgba8, ..Default::default() })?;
    Ok(())
}

Input sources: FlashRaw::open(&[u8]) (zero-copy borrow), open(Vec<u8>), open(Arc<[u8]>), open(memmap2::Mmap), open_path(path), from_reader(reader).

Other entry points: decode_region(rect, opts), decode_tile(index, opts), units() (independently decodable tiles/strips with byte ranges), capabilities(), previews() / thumbnail() / decode_preview_rgb(), flashraw::read_metadata(bytes), flashraw::supports(bytes).

Output formats: RawU16 (default), RawF32, NormalizedF32 (black-subtracted, white-scaled), linear sRGB-primaries RGB as LinearRgbF32, LinearRgbF16 (half floats, half the memory) or LinearRgb16, and display-ready sRGB as Rgba8 or Rgb16 (16-bit, orientation applied; with a standard tone by default, Tone::Linear for none). RGB outputs take exposure (EV) and black_point / white_point convenience controls. Statistics (frame.stats()) report per-stage timings and the backend that ran.

🐍 Python

pip install flashraw
import flashraw

with flashraw.open("photo.NEF") as raw:
    print(raw.metadata.camera.name, raw.metadata.exposure.iso)
    sensor = raw.decode().array                  # numpy uint16 (h, w), zero-copy
    rgba = raw.decode(output="rgba8").array      # numpy uint8 (h, w, 4), display-ready

Decoding releases the GIL, so Python threads decode files in parallel. See docs/python.md.

🌐 Browser and Node.js (npm)

import { FlashRaw } from "flashraw";

const buffer = await (await fetch("/photo.CR3")).arrayBuffer();
const raw = await FlashRaw.open(buffer);

console.log(raw.metadata.camera, raw.metadata.width, raw.metadata.height);
const preview = await raw.preview();                      // embedded JPEG, instantly
const frame = await raw.decode({ backend: "auto", output: "raw-u16" });
console.log(frame.width, frame.height, frame.cfa, frame.backend, frame.timings);

const img = await raw.decode({ output: "rgba8" });
ctx.putImageData(new ImageData(img.data, img.width, img.height), 0, 0);
raw.close();

See npm/README.md for Node, React/Vite, Web Workers, metadata-only, preview extraction, GPU and CPU fallback examples, and docs/wasm.md.

🔧 C

#include <flashraw.h>

flashraw_file *f = NULL;
if (flashraw_open_path("photo.NEF", NULL, &f) != FLASHRAW_OK) {
    fprintf(stderr, "%s\n", flashraw_last_error_message());
    return 1;
}
flashraw_decode_options o;
flashraw_decode_options_init(&o);
o.output = FLASHRAW_OUTPUT_RGBA8;
flashraw_frame *fr = NULL;
if (flashraw_decode(f, &o, &fr) == FLASHRAW_OK) {
    const uint8_t *rgba = flashraw_frame_data(fr);  /* width x height x 4 bytes */
    flashraw_frame_free(fr);
}
flashraw_file_free(f);

➕ C++

#include <flashraw.hpp>

flashraw::file raw = flashraw::file::open("photo.CR3");   // throws flashraw::error
flashraw::decode_options o;
o.output = flashraw::output_format::linear_rgb_f32;
flashraw::frame img = raw.decode(o);
flashraw::span<const float> rgb = img.f32();             // no copy

Build with cargo build --release -p flashraw-capi or install with CMake (find_package(flashraw), pkg-config). See docs/c-api.md.

🔁 Coming from LibRaw?

flashraw-libraw-compat implements the commonly used part of the LibRaw C API (libraw_init, libraw_open_file, libraw_unpack, libraw_dcraw_process, libraw_dcraw_make_mem_image, …) on top of FlashRaw. Keep your #include <libraw/libraw.h>, recompile against its headers and link -lraw from FlashRaw. See docs/libraw-compat.md for the supported subset and deviations.

💻 CLI

cargo install flashraw-cli                          # CPU only: no `gpu` and no `jpegxl` feature
cargo install flashraw-cli --features gpu,jpegxl    # + GPU backend (`--backend gpu`) and JPEG XL DNG
# from a checkout: cargo install --path crates/flashraw-cli [--features gpu,jpegxl]

flashraw info photo.CR3                     # summary (--json for machine output)
flashraw dump-metadata photo.ARW            # everything, as JSON
flashraw decode photo.NEF out.raw           # raw u16 samples (.pgm/.tiff also supported)
flashraw decode photo.RAF out.jpg --output rgba8 --profile
flashraw decode photo.DNG tile.pgm --tile 12
flashraw decode photo.DNG crop.pgm --region 1000,800,512,512
flashraw preview photo.CR2 preview.jpg      # embedded full-size JPEG
flashraw thumbnail photo.CR2 thumb.jpg
flashraw benchmark photo.NEF --iterations 10 --threads 8
flashraw verify photo.ORF --json            # geometry, levels and full-buffer hashes
flashraw verify cut.DNG --json --strict     # fail on truncated data (default: recover + warnings)
flashraw supported                          # format/mode support matrix
flashraw camera-db validate|generate|compare|stats|coverage|crops|probe

Options of decode and benchmark (flashraw decode --help is authoritative): --format, --backend auto|cpu|simd|gpu, --output raw-u16|raw-f32|normalized|linear-rgb|linear-rgb16|linear-rgb-f16|rgba8|rgb16, --region x,y,w,h, --tile N, --threads N, --demosaic bilinear|half, --no-opcodes, --exposure EV, --black-point V, --white-point V, --tone standard|linear, --strict, --preview-fallback, --color-space srgb|display-p3|adobe-rgb|prophoto|rec2020, --output-profile FILE.icc, --intent perceptual|relative|saturation|absolute, --bpc, --profile, --json. Names differ slightly between bindings: docs/api-names.md.

$ flashraw decode photo.DNG out.jpg --output rgba8 --profile
Container parse:             0.05 ms
Pixel unpack:                4.75 ms
Post-process:               28.82 ms
Total:                      34.85 ms

Backend:
  decode: CPU SSE4.1 x16 threads
  postprocess: CPU x16

📚 Reference

Truncated and corrupt sensor data

A strip, tile or other sensor-data range that runs past the end of the file is never silently zero-filled. DecodeOptions::corruption_policy decides what happens:

Only the data a decode needs is checked: metadata, previews and region decodes that do not touch the missing data work normally. Short data that still holds every sample is complete: the last row needs no padding to the row stride, and a declared length beyond the last needed sample may run past the end of the file. Recovery covers uncompressed and bit-packed payloads in every format and compressed DNG strips/tiles (a unit that is truncated or fails to decode is zero-filled with a warning), and Nikon and Pentax Huffman and Samsung SRW streams cut short by the end of the file (the rows decoded from real data are kept). Other compressed streams (one entropy-coded stream per image) fail under both policies; when their declared range runs past the end of the file the error carries the same truncation details. A file cut inside its directory structure, before the raw image's IFD, fails with Error::CorruptFile: a thumbnail or preview is never decoded in place of the sensor image.

Undecodable sensor data

Sensor data in a codec FlashRaw cannot decode (for example a mode it does not implement yet) fails with Error::UnsupportedCompression, also for RGB outputs. With DecodeOptions::preview_fallback, Rgba8 and LinearRgbF32 decodes return the embedded full-size preview instead, explicitly marked: frame.source == FrameSource::Preview and a DecodeWarning whose reason is CorruptReason::PreviewFallback. Such a frame is the camera's 8-bit rendering, not sensor data; raw outputs and regions never fall back. The CLI (--preview-fallback), JavaScript (previewFallback), Python (preview_fallback=) and C (flashraw_decode_options.preview_fallback, flashraw_frame_source()) expose the same option.

GPU

Build with --features gpu. Packed/uncompressed payloads are unpacked on the GPU; black subtraction, demosaic, white balance, colour conversion and sRGB encoding run as WGSL compute shaders shared by native (Vulkan/Metal/DX12) and browser (WebGPU) builds; results can stay GPU-resident. Backend::Auto only picks the GPU when its measured cost model predicts a win. See docs/gpu.md.

API stability

FlashRaw follows semver. The public API is everything documented at the crate root: FlashRaw, Source, DecodeOptions and its enums, RawFrame, the metadata types, Error, and the gpu module (feature gpu).

Cargo features

feature default effect
rayon yes multithreaded decoding
simd yes SIMD unpack kernels (SSSE3/SSE4.1 on x86-64 with runtime dispatch, NEON, WASM SIMD128)
mmap yes memory-mapped open_path
gpu no wgpu backend (Vulkan / Metal / DX12 / WebGPU)
jpegxl no JPEG XL compressed DNG (DNG 1.7)
icc yes arbitrary ICC output profiles (DecodeOptions::output_profile); the built-in colour spaces and their profiles need no feature. Every feature and dependency: docs/building.md
serde no Serialize and Deserialize for metadata and option types

📖 Documentation

Architecture · Formats · Building and features · Colour management · Benchmarks · GPU · WASM · C and C++ API · LibRaw-compatible API · Python · Packages · Releasing · Names across bindings · Testing · Profiling · Camera DB · Contributing · Security · Decoder contract · For coding agents · References

📄 License

Code and data (including crates/flashraw-camera-db/data/): MIT OR Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.


FlashRaw
Built by @ybouane · Live demo · used in LightFlow and ImageFlow

flashraw (ybouane/flashraw)

vulkan-api
Searching Database…

What is this?FlashRaw is a fast, memory-safe camera RAW decoder written in Rust that turns a RAW file into raw sensor data, embedded previews, or a display-ready sRGB image, with official bindings for C, C++, Python and JavaScript.
Is this a Rust crate, a CLI, or a full SDK?It is a Rust core library that also ships a CLI and official bindings for C, C++, Python and JavaScript/WASM, so you can use it as a native crate, a command-line tool, or embed it in another language.
How do I add FlashRaw to my project?Pull the Rust crate from crates.io, the Python package from PyPI, or the npm package, depending on your language; docs/packages.md lists every package and its exact install command.
Does it decode every RAW file out there?It decodes 98.2% of the 2,016-file raw.pixls.us test corpus (1,980 files); the remaining 36 are formats not yet supported, like most Nikon High Efficiency NEF, or files that aren't actually RAW.
Which platforms is it actually tested on?Only Linux x86-64 and macOS arm64 are regularly tested natively, plus WebAssembly in browsers and Node.js; Windows and other architectures are not regularly tested.
What RAW formats can it decode?About 40 formats, including Canon CR3 (and C-RAW), JPEG XL DNG, lossy/deflate DNG, GoPro GPR, Sigma X3F, Fuji compressed files, Panasonic v4-v8 and IIQ/3FR/FFF.
How much faster is FlashRaw than LibRaw?On the same machine and files it decodes 7.9x-11.4x faster than LibRaw and produces a full sRGB image 8.8x-15.4x faster, while using 1.5x-1.9x less memory.
Who is already using FlashRaw?Two browser-based photo editors, LightFlow and ImageFlow, both open camera RAW files directly in the browser using FlashRaw's WebAssembly package.
Is it safe to run on untrusted RAW files?Yes - it's written in memory-safe Rust with bounds-checked parsing and allocation limits, and is tested against 15 fuzz targets before every release.
What are similar projects?lightcraft, ggml, CalibRaw, gpu.js, WasmEdge, liteparse, rembrandt, Raven
Creator
ybouane
Size
19.9 MB
Stars
122
Age
2mo
Commits · 90 Days