Photo develop — local, incremental session pipeline
This skill never edits source photographs. It reads the pre-cull report, Sony
ARW and matching camera JPEGs; outputs are written to a separate photo-ai
folder by default. No GPU, no network, no runtime model inference.
What changed, and why
The first version wrote a sidecar with almost everything at zero (exposure, shadows and highlights only, bounded to ±0.7 EV) and drew the preview with Pillow brightness on a LibRaw decode that sits 2–3 stops below what Lightroom shows. Two consequences: there was nothing to tune in the XMP, and the preview did not represent the sidecar.
The current engine measures the RAW, measures the renderer, and writes a real tone curve:
- Measure the RAW, not the camera JPEG: per-channel clipping, highlight headroom, shadow noise σ, LED banding, neutral-patch cast.
- Render an identity baseline of that frame with neutral settings using the same renderer as the export (LightCraft CPU, or the built-in LibRaw path). That baseline carries the renderer's own base look.
- Compute a residual tone curve from that baseline towards the target (the sibling camera JPEG, else the embedded thumbnail): a monotone 256-point percentile map in log luminance. Because it is a residual, applying it can never double-brighten.
- Write
crs:ToneCurvePV2012+Exposure2012+Vibrance+ adaptiveSharpness/noise reduction + a small optionalTemperature/Tinttrim. - Blend 30% towards the lighting-moment median (same ISO bucket and same 5-minute capture window) so a burst does not flicker.
- Render the preview from the same sidecar with the same renderer, measure it against the target, and correct the one systematic drift (chroma) by re-rendering once. What is reviewed is what the export will produce.
Run
python "$env:USERPROFILE\.config\opencode\skills\photo-develop\scripts\run_pipeline.py" `
--source "C:\path\to\session" `
--cull "C:\path\to\pre-cull-report" `
--output "C:\path\to\session\photo-ai"
--adjacent-sidecars also copies generated XMP beside its ARW for Lightroom
discovery, only where no sidecar exists. .state.json fingerprints inputs and
checkpoints completed frames; re-running skips unchanged work.
Flags that matter:
| Flag | Effect |
|---|---|
--lightcraft-cli PATH | explicit renderer; otherwise auto-detected (LIGHTCRAFT_CLI, PATH, C:\Program Files\LightCraft) |
--no-lightcraft | never call LightCraft; built-in LibRaw renderer for identity and preview |
--fast | skip the LightCraft identity render (decode baseline; approximate) |
--no-refine | skip the correction pass that re-renders when the measured preview drifts in chroma |
--no-scene-grouping | keep every frame fully individual (no group blend) |
--wb-trim | allow a small Temperature/Tint trim from confident neutral patches (off: warm light is usually intentional) |
--sample N | process only the first N ranked keepers |
--no-previews | sidecars + report only |
--force | regenerate pipeline-owned outputs (never touches originals) |
--profile PATH | session-specific style profile |
LightCraft is invoked as lightcraft-cli render <arw> --settings <xmp> with
LIGHTCRAFT_GPU=0 and LIGHTCRAFT_NO_PREFS=1, so its CPU path is forced and no
user preference leaks into the render.
Output contract
photo-ai/scores.json preserves every input cull record and adds a develop
object per analysed frame: settings, xmp, preview, method, rationale
(exposure, curve shape, chroma ratio, noise σ, sensor clipping, white-balance
decision) and estimated_delta_e. photo-ai/metadata.json carries counts, the
engine version, the fidelity summary measured on the rendered previews
(tone_error_mean, tone_error_max, chroma_ratio_mean) and every warning.
photo-ai/report.html is a standalone searchable report with before/after
previews, per-frame rationale and fidelity. photo-ai/xmp/*.xmp are Adobe
Camera Raw sidecars (ToneCurvePV2012 included). .state.json is the resume
checkpoint. docs/evidence/final/ holds camera-JPG / old-export / new-engine
comparison rows.
ARW originals are never modified. Sidecars stay in the output folder unless
--adjacent-sidecars is passed, and existing adjacent sidecars are never
overwritten.
Preferences and feedback
~/.config/opencode/photo-develop/style-profile.json is the persistent profile
(override per session with --profile). It never invents a style.
python "$env:USERPROFILE\.config\opencode\skills\photo-develop\scripts\update_preferences.py" `
--feedback "C:\path\to\my-feedback.json" `
--profile "$env:USERPROFILE\.config\opencode\photo-develop\style-profile.json"
Feedback rows are deduplicated by stable ID. Only explicit
approved_settings - suggested_settings deltas are learned, and every delta is
bounded. With at least 8 approved edits the profile stores a ridge regression
over frame features (ISO, luminance, clipping), so the nudge is conditional on
the kind of frame instead of one global average; with less history it stores the
plain mean and says so. Preferences may also set curve_strength (0..1) to keep
more of the renderer's own look.
Decisions and limits
Pre-cull classifications and near-duplicate groups are input evidence, not artistic truth. The runner marks the technical keeper but keeps alternates visible. Tone is matched to the camera JPEG because that is a defensible, per-session target; it is not a claim about what the photograph should express. Skin tone, expression, pose, narrative and crop still need a human or a vision agent.
The tone curve is calibrated per frame against the renderer's identity baseline.
If you change renderer, re-run with --force so the curve is recomputed rather
than reused: ENGINE_VERSION invalidates the state automatically, but switching
between --no-lightcraft and LightCraft does not change that constant.
LightCraft renders are not Adobe Camera Raw. XMP values are standard Camera Raw fields; verify in the target Lightroom version before batch adoption. HSL, lens/profile corrections and precise composition crops are still not guessed.
CPU / GPU guarantee
Uses rawpy (LibRaw), numpy, OpenCV, Pillow and the standard library. GPU
environment flags are disabled before importing image libraries; no ONNX,
MediaPipe or FocalNet is loaded. --sample is recommended before a full run.
Tests
python -m unittest discover -s scripts/tests -v
Covers curve monotonicity and percentile accuracy, curve strength, exposure in linear light, neutral-settings identity, XMP round-trip (256 points), scene grouping, ridge regression, white-balance conservatism and bounds clamps.