# Recipe Lab in Photo Lab

Recipe settings are adapted from [Recipe Lab](https://github.com/voxivoid/recipe-lab-sony-pmca),
revision `15556b4f98368a1ecf14ef2b696b3300bdef6ae7` (29 October 2026),
copyright 2026 André Domingues. The actual LICENSE at this revision is GPL-3.0,
not MIT. The upstream README says only releases through v1.7.0 were MIT.
A copy is in [RECIPE-LAB-LICENSE.txt](RECIPE-LAB-LICENSE.txt). The extracted
catalogue and adapted format handling retain that licence. The added integration
is distributed under GPL-3.0 with the source in this directory, without warranty.
LibRaw retains its separate LGPL/CDDL licensing.

The 77 original settings records live in `src/recipe-catalog.mjs`. Rebuild them
with `python3 tools/extract-recipes.py /path/to/recipe-lab-checkout` at the pinned
revision. Original numeric Creative Style enums are resolved to upstream runtime
names. All other Sony values, including exposure in thirds, are kept intact.
Mike's fifteen favourites appear first, in the order supplied on 3 November.

## What a look means

These are approximations of camera recipes, which are themselves interpretations
of named film stocks and other cameras. They are not measured reproductions of
those stocks or of Sony's JPEG engine. `src/sony-recipes.mjs` owns the mapping:

- Creative Style selects a tone and colour base. Standard, Vivid and mono can be
  fitted to the supplied camera references. Other styles remain unmeasured.
- Contrast scales the tone-curve slope by `2^(adjustment × 0.105)`; saturation
  scales style chroma by `1 + adjustment × 0.17`. Sony's exact steps are unknown.
- Amber/blue and green/magenta shifts use small channel gains before the curve.
  RAW Kelvin replaces the as-shot balance using the camera's per-file Kelvin
  table. Auto uses its unshifted auto estimate, then applies the requested shift
  once. Keep retains as-shot. JPEGs keep the relative creative colour cast.
- Exposure thirds describe a camera capture instruction. RAW development keeps
  the captured exposure and does not add that bias again. Direct Light exposure
  remains in reach. JPEGs keep the develop approximation.
- DRO is fixed shadow lift. Sony's adaptive, scene-dependent processing is absent.
- Toy, Pop, Retro, Soft High Key, high-contrast and rich-tone mono have rough
  interpretations. Active effects override Creative Style. Posterization, partial
  colour, soft focus, HDR art, miniature, illustration and watercolour remain
  unsupported and are explicitly flagged. Their effect options are preserved.
- Sony recipe sharpness is preserved but its exact steps remain unmeasured.
  ISO-aware noise reduction, capture sharpening and metadata lens correction use
  the same full-size develop in preview and export. See RAW-DEVELOPMENT.md.

Every recipe exposes its original settings and its own list of ignored settings
in the picker. A look on a JPEG grades already-rendered pixels; use an ARW to
compare recipes after capture. Export creates a new file, with no write to the
original. Imported YAML is the upstream flat format 1, with the same keys, value
ranges, comments, quoted values and missing-value defaults. Unknown keys are
ignored for upstream forward compatibility. Unknown format versions fail.

## Camera reference and matching

`src/sony-meta.mjs` reads TIFF byte order, EXIF offsets and Sony's MakerNote IFD,
including signed adjustment tags and `WBShiftAB_GM` (0x2014). It also deciphers
NEX-6 tag 0x2010e for DRO and the secondary effect code. Other bodies' encrypted
layouts are not guessed. Missing tags remain unknown, never zero by default.
Definitions are checked against [ExifTool's Sony documentation](https://exiftool.org/TagNames/Sony.html)
and its `Sony.pm` source. The standalone development audit used the npm library
`exiftool-vendored` 39.1.0 on all 102 JPEGs, entirely on this machine. The browser
reader has no package or service dependency.

MakerNote GM is positive toward magenta; Recipe Lab GM is positive toward green.
The reader converts the sign explicitly. Recipe names are not stored in photos.
Favourite identification requires equality of every available recipe setting,
including WB shift, DRO and exposure bias. Missing fields prevent an exact match;
multiple matches are shown together. Nearest settings are suggestions with the
mismatching fields, never labels assigned to the photograph.

## Calibration and what it proves

Round two (4 November 2026) refits Standard on **43 FACTORY-compatible pairs** (zero exposure bias and auto DRO), excluding
all 28 A3/G1 pairs and nine other captures, despite their zeroed contrast/saturation fields. The other
styles have 11 mono and six Vivid-labelled pairs. Only global style exposure,
contrast, shoulder knee and saturation are fitted. Mono stays achromatic. No
per-photo parameters are used. Unobserved styles retain their hand mappings.

| Reference set | Pairs | Round-one mean / p95 ΔE00 | Round-two mean / p95 ΔE00 |
|---|---:|---:|---:|
| Plain Standard / FACTORY | 43 | 3.28 / 9.58 | 2.57 / 6.23 |
| B&W | 11 | 2.02 / 4.21 | 1.50 / 3.75 |
| Vivid-labelled | 6 | 5.45 / 12.39 | 4.77 / 10.85 |
| Gold WB/exposure fingerprint | 26 | 6.48 / 10.89 | 2.94 / 6.58 |

Every fourth plain file is held out: 32/11 Standard, 8/3 mono, 4/2 Vivid. Mean
holdout error improves in every style. Mono's holdout p95 worsens from 4.77 to
5.17; the fit is not a uniform improvement. Related scenes occur in both sets,
so this is not an independent new-roll validation.

The full-resolution shared RAW path is downscaled to 320px for colour metrics.
Each pipeline stage has a neutral-source affine ECC alignment frozen before
fitting. The common border mask across stages excludes 5% of the shorter edge. One
featureless frame uses identity fallback in two geometry stages and remains in
the scores; it is not silently discarded.
Fixed 0.6px smoothing suppresses small noise/demosaic differences. Metrics use
D65 CIE Lab and pooled CIEDE2000, including a pooled pixel 95th percentile.
The original half-size source and untouched round-one renderer provide the
before baseline. Single-component lens ablations are diagnostic 320px warps;
the final combined lens path is corrected at full resolution before downscaling.

### Kodak Gold's settings conflict

All 28 A3/G1 Standard pairs favour zero contrast/saturation over the advertised
+1/+2. Mean/p95 is 2.84/6.44 versus 3.77/7.17 with the boosts, using the same
plain-only Standard fit, lens path and WB. The 26 sharing Gold's exposure bias
form the recipe score above. Photo Lab renders that observed zero-knob behaviour
for the Gold signature while retaining the original settings for display/YAML.
That is evidence of ignored boosts in these files, not proof about every camera
firmware or Recipe Lab version. Other recipes are not silently changed.

A separately confirmed Gold selection records Vivid and zero WB shift instead of
the expected fingerprint. It is kept separate from the A3/G1 group: the JPEG
cannot establish that all requested Gold settings landed. The local report keeps
the per-photo identification and measurements.
No other nonzero-WB favourite fingerprint occurs in the 97 pairs. Zero-shift
recipes remain ambiguous; contrast/saturation fields alone cannot identify them.

The supplied set contains 97 unique RAW+JPEG pairs, two duplicate JPEGs, three
JPEG-only photos and five RAW-only photos. Independent ExifTool ISO inspection
of all 204 files found ISO 100–3200, not ISO 25600. Higher-ISO settings are tested
synthetically and remain unmeasured against this camera.

### Reproducing round two

Private pixels, manifests and per-photo measurements stay outside git. The
preparation takes the previous calibration manifest and linear baseline files,
then reopens the original RAWs through the current developer:

```sh
node tools/camera-parity-prepare.mjs /private/previous-calibration /private/round-two
git archive 59992261 projects/photography-lab/src | tar -x -C /private/baseline-code
python tools/camera-parity.py /private/round-two --baseline-src /private/baseline-code/projects/photography-lab/src
```

The Python driver needs NumPy, SciPy, scikit-image, Pillow and OpenCV. It uses
`camera-parity-render.mjs` to call the actual JS renderer, writes results.json,
and closes its child process. `calibration-groups.mjs` owns the plain-set
selection and has regression tests for the shifted-zero-knob case. Transfer
accepted global parameters into `src/sony-calibration.mjs` and rerun the suites.
