Skip to content

Databases

botrx555 edited this page Jul 14, 2026 · 2 revisions

Databases - lensdb.ini and sensdb.ini

Two optional INI files kept next to the script (or pointed to with --db-dir) hold the per-body and per-lens calibration the converter applies. Both are plain text you can read and edit.

sensdb.ini - per-body sensor calibration

Written by -sd and --calibrate-fnumber, read by -s. Keyed by body serial.

[<body-serial>]
LevelCorrection = <float>          ; one value per image column
...
Line = x1 y1 x2 y2                 ; m8raw2dng2 defect-column run (one key)
MeterOffset.<6bitcode> = <float>   ; aperture-meter offset (--calibrate-fnumber)
ImageCalib.<6bitcode>  = <float>   ; meter<->image cross-check constant
  • LevelCorrection - the darkfield, one value per image column (see The Math).
  • Line - a defect-column run, neighbour-interpolated on every -s.

Defect-column encoding differs between the tools

m8raw2dng2 writes a defect run as one Line = x1 y1 x2 y2 key. The original instead wants four separate Line = keys under the serial - one integer each, in order x1, y1, x2, y2 (the two x values equal for a vertical column) - because its reader does one atoi per Line key and accumulates the four into a run:

[3196881]
Line = 91
Line = 0
Line = 91
Line = 2645
LevelCorrection = ...

m8raw2dng2 reads both encodings, but a sensdb.ini written by one tool is not consumed as-is by the other. The RAW-space column numbers are identical, though, so a column m8raw2dng2 detects (say 91) is the same x you would hand-write for the original.

The deeper difference is automation. The original has no Line writer at all

  • only readers - and its -sd emits zero Line entries, so defect columns must be entered by hand and then checked with -st, which paints the named columns bright (without interpolating) so you can verify the coordinates by eye before a plain -s darkfield-flattens them away. m8raw2dng2 -sd --auto-lines detects the stuck columns automatically and writes them for you. When hand-entering for the original, remember the RAW carries the 2px border the DNG drops: add 2 to every x and y read off a DNG.
  • MeterOffset.<code> - the per-(body, lens) aperture-meter offset from --calibrate-fnumber.
  • ImageCalib.<code> - the meter-vs-image cross-check constant.

lensdb.ini - per-lens EXIF

Authored by hand, read by -l. Keyed by 6-bit lens code.

[<6bitcode>]
Maker = <maker>
Model = <model>
SerialNo = <serial>
FocalLength = <mm>
Aperture = 2.0
Aperture = 2.4
...

-l <code> fills LensMake / LensModel / LensSerialNumber, the focal length and its 35 mm equivalent (x 1.33 M8 crop) and the APEX maximum aperture, and snaps the estimated FNumber to the listed apertures. The repeated Aperture lines are the lens's aperture scale, one per stop.

The 6-bit lens code

The 6-bit code is the bit pattern on the lens bayonet read from behind (black = 1, white = 0); 000000 is un-coded. The M8 only records a code when the frame-line lever matches the mounted lens, so for an un-coded or mis-levered lens, force the code you want with -l <6bitcode>. See Glossary for more on 6-bit coding.

Clone this wiki locally