Skip to content

File Formats

botrx555 edited this page Jul 14, 2026 · 3 revisions

File Formats

The RAW dump

21,049,052 bytes total, little-endian 16-bit samples:

  • 54 leading samples - skipped (header).
  • 2646 rows x 3976 samples per row; only the first 3968 samples of each row are image data (the remaining 8 are discarded).
  • one trailing stride-row - ignored.
  • values clamped to 16383 (14-bit).

The decode yields the raw CFA mosaic - one 14-bit value per photosite, no rendering applied. The RAW carries no EXIF; all metadata comes from the paired .JPG.

The JPG companion

Same filename stem as the .RAW. It is the sole metadata source: EXIF plus the Leica MakerNote (copied verbatim into the DNG), which carries body serial, ISO, exposure, focal length and the two light-meter readings used for aperture recovery. See The Math.

The BIA bias frame

Optional sidecar (same stem, .bia). The M8 writes it automatically on long exposures (rarely on some dark frames), so treat it as optional and non-deterministic. When present, it is subtracted from the CFA and BlackLevel is forced to 0. See The Math.

Geometry

Quantity Value
Full frame written (strip) 3968 x 2646
Default DefaultCropOrigin (2, 2)
Default DefaultCropSize 3964 x 2642
--no-crop DefaultCropOrigin (0, 0)
--no-crop DefaultCropSize 3968 x 2646
CFA pattern RGGB (default; set with --cfa)

The full 3968 x 2646 pixels are always written; --no-crop changes only the DefaultCrop tags, never the pixel data (the two outputs differ by exactly 4 bytes). The default 2px border crop matches the original tool's output.

The original additionally reads a different geometry as a second input mode: a genuine in-camera standard M8 DNG is 3920 x 2638, 8-bit - not the 3968 x 2646 RAW dump. Both width constants (3968 and 3920) live in the binary. m8raw2dng2 works only with the RAW+JPG format above; the standard-DNG path is the original's alone (see The Original Tool).

That 2-px border is genuine sensor data, not black and not masked optical-black: the border pixels are ordinary photosites, continuous with the scene (on a lit frame the border reads close to the adjacent interior; on a dark frame it sits at the same pedestal as the interior). It is a thin demosaic-quality margin trimmed by DNG convention, and the original tool's DNG carries the identical crop tags - so both open the same way in ACR/Photoshop.

The DNG output

A hand-built little-endian TIFF (no library needed to write it), structured:

  • IFD0 (47 tags)
  • EXIF sub-IFD (21 tags)
  • MakerNote (copied verbatim)
  • Leica M8 colour matrices (Standard-A + D65 illuminants; -c swaps ColorMatrix1/2 to the M9 "M8RAW" set and renames the Model tag to "M8RAW Digital Camera", leaving UniqueCameraModel, the illuminants and CameraCalibration unchanged)
  • a single uncompressed strip of 16-bit linear CFA samples

Key tags: WhiteLevel 16383; CFA phase from --cfa; BlackLevel written only with -b (tag only - see The Math); DefaultCrop as above. AsShotNeutral is computed per shot from that frame's own data (not a fixed daylight value stamped on every file), matching the original - so two frames can legitimately carry different AsShotNeutral values. The Software tag carries the firmware string read from the source JPG, and is omitted when the JPG has none; UniqueCameraModel is M8 Digital Camera. Focal-plane resolution tags are fixed M8 values.

Preview layouts

  • Default layout: the raw sits in IFD0, byte-identical to the original tool's own default output.
  • --legacy-preview: puts a sharp 3:2 JPEG preview in IFD0 and the raw CFA in a SubIFD - the standard in-camera M8 layout (the original's -p follows the same two-IFD structure but embeds only a small 320 x 240 preview; --legacy-preview embeds a full-resolution JPEG). Fixes macOS Finder / QuickLook thumbnails and keeps files small. The preview is a baseline JPEG (YCbCr 4:2:0) written with the same tag set Adobe Camera Raw uses, so files land around 21 MB (just above the raw-strip floor) rather than the ~23 MB of a full uncompressed preview. --preview-size sets the long edge (default 1024); --preview-uncompressed embeds RGB instead of JPEG (a fallback, not a quality switch - same pixels). The preview is auto-cleaned of hot-pixel and shadow chroma noise; the raw CFA is never touched.

Raw pixels are identical across all preview options.

Clone this wiki locally