Land camera-native raw profiles, real ICC soft proofing and 16-bit proxies.

Camera profiles, proofing tables and the half-float sidecar all have to agree
with the pixels the editor actually grades, so they land together with the
preset filter menu that was unusable while thumbnails streamed in.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 03:59:55 +00:00
parent 6dfddffc14
commit 0c113e7a91
53 changed files with 9217 additions and 476 deletions
+147 -37
View File
@@ -7,7 +7,8 @@ import {
MAX_LOCAL_LAYERS,
} from '../lib/edits';
import { subscribeClipPreview } from '../lib/clipPreview';
import { getBitmap, getDenoisedBitmap } from '../lib/images';
import { get16BitSource, getBitmap, getDenoisedBitmap } from '../lib/images';
import type { Preview16 } from '../lib/preview16';
import { useMediaQuery } from '../lib/useMediaQuery';
import { usePersistentState } from '../lib/usePersistentState';
import { solveWhiteBalance } from '../lib/whiteBalance';
@@ -59,6 +60,7 @@ import {
OpticsPanel,
PresetsPanel,
ProofPanel,
CameraProfilePanel,
SnapshotsPanel,
} from './Panels';
import Stars, { ColorSwatches, FlagButtons } from './Stars';
@@ -121,6 +123,8 @@ interface Props {
onSelect: (id: string) => void;
onExit: () => void;
onUpdate: (id: string, patch: Partial<PhotoRecord>, historyLabel?: string) => void;
/** Auto-sync: merge a patch into several photos' own edits at once. */
onUpdateEdits?: (ids: string[], patch: Partial<Edits>, historyLabel?: string) => void;
clipboard: Edits | null;
onCopy: () => void;
/** Copy settings from a named filmstrip photo instead of the canvas photo. */
@@ -138,6 +142,7 @@ interface Props {
onOpenImmich?: () => void;
presets: Preset[];
onSavePreset: (name: string, edits: Edits) => void;
onDeletePreset: (id: string) => void;
onDelete: () => void;
onVirtualCopy: () => void;
metadataPresets: MetadataPreset[];
@@ -156,6 +161,7 @@ export default function Develop({
onSelect,
onExit,
onUpdate,
onUpdateEdits,
clipboard,
onCopy,
onCopyOf,
@@ -170,6 +176,7 @@ export default function Develop({
onOpenImmich,
presets,
onSavePreset,
onDeletePreset,
onDelete,
onVirtualCopy,
metadataPresets,
@@ -189,7 +196,10 @@ export default function Develop({
const panRef = useRef<{ x: number; y: number; cx: number; cy: number } | null>(null);
const [bitmap, setBitmap] = useState<ImageBitmap | null>(null);
const [hdrSource, setHdrSource] = useState<Preview16 | null>(null);
const [denoisedBitmap, setDenoisedBitmap] = useState<ImageBitmap | null>(null);
/** Name of the printer ICC profile loaded for this session, if any. */
const [proofProfile, setProofProfile] = useState<string | null>(null);
const [stage, setStage] = useState({ w: 0, h: 0 });
const [cropMode, setCropMode] = useState(false);
const [cropDrag, setCropDrag] = useState(false);
@@ -214,6 +224,7 @@ export default function Develop({
const [filmSel, setFilmSel] = useState<string[]>([photo.id]);
const [filmAnchor, setFilmAnchor] = useState(photo.id);
const [showOriginal, setShowOriginal] = useState(false);
const [autoSync, setAutoSync] = usePersistentState('develop.autosync', false);
const [histVersion, setHistVersion] = useState(0);
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState(true);
@@ -232,6 +243,7 @@ export default function Develop({
ids?: string[];
} | null>(null);
const [healMode, setHealMode] = useState(false);
const [rangePicking, setRangePicking] = useState(false);
const [brushPx, setBrushPx] = useState(56);
const [healFeather, setHealFeather] = useState(50);
const [healSelected, setHealSelected] = useState<number | null>(null);
@@ -340,9 +352,17 @@ export default function Develop({
const setEdits = useCallback(
(patch: Partial<Edits>, label: string) => {
// Auto-sync applies only the changed controls to the rest of the
// filmstrip, so each photo keeps its own untouched settings, crop and
// masks. The canvas photo is always updated last so the preview follows
// the slider that was actually moved.
if (autoSync && filmSel.length > 1 && onUpdateEdits) {
const others = filmSel.filter((id) => id !== photo.id);
if (others.length) onUpdateEdits(others, patch, label);
}
onUpdate(photo.id, { edits: { ...photo.edits, ...patch } }, label);
},
[onUpdate, photo.id, photo.edits],
[autoSync, filmSel, onUpdate, onUpdateEdits, photo.id, photo.edits],
);
useEffect(() => {
@@ -399,6 +419,14 @@ export default function Develop({
useEffect(() => {
let alive = true;
setLoading(true);
// The 16-bit sidecar is optional and can be tens of megabytes, so it loads
// behind the JPEG and simply swaps the source texture when it lands.
setHdrSource(null);
get16BitSource(photo)
.then((hdr) => {
if (alive) setHdrSource(hdr);
})
.catch(() => undefined);
getBitmap(photo)
.then((bmp) => {
if (!alive) return;
@@ -508,22 +536,14 @@ export default function Develop({
let cssH = Math.max(40, Math.round(contentH * fitScale));
if (zoomFactor > 1.0001) {
// The visible window keeps the stage's aspect, so the canvas is stage sized
// and the shader maps it onto a sub-rect of the frame. Cost stays constant
// no matter how far you zoom, and detail comes from the source bitmap.
const vw = Math.min(1, availW / (fitScale * zoomFactor) / frame.w);
const vh = Math.min(1, availH / (fitScale * zoomFactor) / frame.h);
const cx =
vw >= content.w
? content.x + content.w / 2
: clampNum(zoom.cx, content.x + vw / 2, content.x + content.w - vw / 2);
const cy =
vh >= content.h
? content.y + content.h / 2
: clampNum(zoom.cy, content.y + vh / 2, content.y + content.h - vh / 2);
// The canvas keeps the photo's fit-sized box while zooming and the window
// shrinks inside the crop at the same aspect. Growing the canvas to the
// stage's shape instead stretched any photo whose aspect differed from it.
const vw = content.w / zoomFactor;
const vh = content.h / zoomFactor;
const cx = clampNum(zoom.cx, content.x + vw / 2, content.x + content.w - vw / 2);
const cy = clampNum(zoom.cy, content.y + vh / 2, content.y + content.h - vh / 2);
view = { x: cx - vw / 2, y: cy - vh / 2, w: vw, h: vh };
cssW = Math.round(availW);
cssH = Math.round(availH);
}
const dpr = Math.min(window.devicePixelRatio || 1, 2);
@@ -555,7 +575,7 @@ export default function Develop({
);
try {
renderer.setImage(bitmap);
renderer.setImage(bitmap, hdrSource);
// "Show original" must show the untouched source, not the cleaned proxy.
renderer.setDenoised(showOriginal ? null : denoisedBitmap, activeEdits.aiDenoise.amount / 100);
renderer.render(activeEdits, {
@@ -583,6 +603,7 @@ export default function Develop({
}
}, [
bitmap,
hdrSource,
denoisedBitmap,
edits,
cropMode,
@@ -595,6 +616,9 @@ export default function Develop({
lensCorrection,
lensSplit,
lensSplitAt,
// Loading or clearing a printer profile changes the finish pass, and the
// cube lives outside the edit record, so the redraw is keyed on it here.
proofProfile,
]);
useEffect(() => {
@@ -634,11 +658,11 @@ export default function Develop({
}
}
const vw = geo.availW / (geo.fitScale * zNext) / geo.frameW;
const vh = geo.availH / (geo.fitScale * zNext) / geo.frameH;
const c = geo.content;
cx = vw >= c.w ? c.x + c.w / 2 : clampNum(cx, c.x + vw / 2, c.x + c.w - vw / 2);
cy = vh >= c.h ? c.y + c.h / 2 : clampNum(cy, c.y + vh / 2, c.y + c.h - vh / 2);
const vw = c.w / zNext;
const vh = c.h / zNext;
cx = clampNum(cx, c.x + vw / 2, c.x + c.w - vw / 2);
cy = clampNum(cy, c.y + vh / 2, c.y + c.h - vh / 2);
setZoom({ pct: next, cx, cy });
}, []);
@@ -653,16 +677,10 @@ export default function Develop({
const pct = zoom.pct === 'fit' ? 100 : zoom.pct;
const z = Math.max(1, pct / geo.fitPct);
const c = geo.content;
const vw = Math.min(c.w, geo.availW / (geo.fitScale * z) / geo.frameW);
const vh = Math.min(c.h, geo.availH / (geo.fitScale * z) / geo.frameH);
const cx =
vw >= c.w
? c.x + c.w / 2
: clampNum(fx, c.x + vw / 2, c.x + c.w - vw / 2);
const cy =
vh >= c.h
? c.y + c.h / 2
: clampNum(fy, c.y + vh / 2, c.y + c.h - vh / 2);
const vw = c.w / z;
const vh = c.h / z;
const cx = clampNum(fx, c.x + vw / 2, c.x + c.w - vw / 2);
const cy = clampNum(fy, c.y + vh / 2, c.y + c.h - vh / 2);
setZoom({ pct, cx, cy });
},
[zoom.pct],
@@ -717,7 +735,7 @@ export default function Develop({
}, [cropMode, applyZoom, healMode, localMode, activeLocal]);
const beginPan = (e: React.PointerEvent<HTMLCanvasElement>) => {
if (picking || cropMode || healMode || localMode || !zoomed || e.button !== 0) return;
if (picking || rangePicking || cropMode || healMode || localMode || !zoomed || e.button !== 0) return;
const geo = geoRef.current;
panRef.current = {
x: e.clientX,
@@ -1007,6 +1025,58 @@ export default function Develop({
[autoMaskBusy, bitmap, commitLocal, edits.local, photo],
);
/**
* Colour-range sampler: read the untouched source colour under the pointer and
* shape the active mask's range around its hue, saturation and luma. The same
* source colour the mask range compares against, so the result lines up even
* under a heavy grade.
*/
const pickRangeColour = (e: React.MouseEvent<HTMLCanvasElement>) => {
if (!rangePicking || !activeLocal) return;
const canvas = canvasRef.current;
const renderer = rendererRef.current;
if (!canvas || !renderer) return;
const rect = canvas.getBoundingClientRect();
if (!rect.width || !rect.height) return;
const geo = geoRef.current;
const sample = renderer.pickSource(edits, {
nx: clampNum((e.clientX - rect.left) / rect.width, 0, 1),
ny: clampNum((e.clientY - rect.top) / rect.height, 0, 1),
view: geo.zoomFactor > 1.0001 ? geo.view : undefined,
upscale: Math.min(window.devicePixelRatio || 1, 2) * geo.fitScale * geo.zoomFactor > 1.1,
});
setRangePicking(false);
if (!sample) return;
const [r, g, b] = sample;
const max = Math.max(r, g, b);
const min = Math.min(r, g, b);
const delta = max - min;
let hue = 0;
if (delta > 1e-6) {
if (max === r) hue = ((g - b) / delta) % 6;
else if (max === g) hue = (b - r) / delta + 2;
else hue = (r - g) / delta + 4;
hue = (hue * 60 + 360) % 360;
}
const sat = max > 0 ? delta / max : 0;
const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
patchLocal(
activeLocal.id,
{
range: {
...activeLocal.range,
enabled: true,
hue: Math.round(hue),
hueRange: 40,
satMin: Math.round(Math.max(0, sat * 100 - 25)),
lumaMin: Math.round(Math.max(0, luma * 100 - 14)),
lumaMax: Math.round(Math.min(100, luma * 100 + 14)),
},
},
'Sample mask colour',
);
};
const deleteLocalLayer = useCallback(
(id: string) => {
commitLocal((edits.local ?? []).filter((layer) => layer.id !== id), 'Delete local adjustment');
@@ -1381,7 +1451,15 @@ export default function Develop({
const next: Edits =
preset.id === 'original'
? { ...defaultEdits(), crop: photo.edits.crop }
: { ...photo.edits, ...preset.edits, crop: photo.edits.crop };
: {
...photo.edits,
...preset.edits,
crop: photo.edits.crop,
// The camera profile belongs to the body that produced the raw.
cameraProfile: photo.edits.cameraProfile,
// A strong film response must not leak into the next look.
redscale: preset.edits.redscale ?? 0,
};
onUpdate(photo.id, { edits: next }, `Preset: ${preset.name}`);
},
[onUpdate, photo.id, photo.edits],
@@ -1433,6 +1511,13 @@ export default function Develop({
onPasteLayer={pasteLocalLayer}
canPaste={Boolean(localClipboard)}
onAutoMask={(kind) => void addAutoMask(kind)}
onSampleRange={() => {
setRangePicking(true);
setLocalMode(false);
setHealMode(false);
setPicking(false);
setCropMode(false);
}}
autoBusy={autoMaskBusy}
/>
<EffectsPanel edits={edits} photo={photo} set={setEdits} grainFreeze={cropDrag} />
@@ -1445,7 +1530,19 @@ export default function Develop({
lensSplit={lensSplit}
onLensSplit={setLensSplit}
/>
<ProofPanel edits={edits} photo={photo} set={setEdits} />
<CameraProfilePanel
edits={edits}
photo={photo}
set={setEdits}
cameraNative={Boolean(hdrSource?.rgbCam)}
/>
<ProofPanel
edits={edits}
photo={photo}
set={setEdits}
proofProfile={proofProfile}
onProofProfile={(cube) => setProofProfile(cube?.name ?? null)}
/>
{includeMetadata && (
<MetadataPanel
photo={photo}
@@ -1597,6 +1694,18 @@ export default function Develop({
>
Before / After
</button>
<button
className={`btn ghost small ${autoSync ? 'on' : ''}`}
onClick={() => setAutoSync((v) => !v)}
aria-pressed={autoSync}
title={
autoSync
? 'Auto-sync on: every adjustment applies to all selected filmstrip photos'
: 'Auto-sync: apply adjustments to every selected filmstrip photo'
}
>
Auto-sync{autoSync && filmSel.length > 1 ? ` (${filmSel.length})` : ''}
</button>
<button className={`btn ghost small ${cropMode ? 'on' : ''}`} onClick={() => setCropMode((v) => !v)} title="Crop & straighten (C)">
Crop
</button>
@@ -1731,6 +1840,7 @@ export default function Develop({
photo={photo}
onApply={applyPreset}
onSave={(name) => onSavePreset(name, photo.edits)}
onDelete={onDeletePreset}
/>
<SnapshotsPanel
snapshots={photo.snapshots ?? []}
@@ -1766,8 +1876,8 @@ export default function Develop({
<div className="canvas-wrap">
<canvas
ref={canvasRef}
className={`preview ${zoomed ? 'zoomed' : ''} ${picking ? 'picking' : ''} ${healMode ? 'healing' : ''} ${localMode ? 'masking' : ''}`}
onClick={pickWhiteBalance}
className={`preview ${zoomed ? 'zoomed' : ''} ${picking || rangePicking ? 'picking' : ''} ${healMode ? 'healing' : ''} ${localMode ? 'masking' : ''}`}
onClick={(e) => (rangePicking ? pickRangeColour(e) : pickWhiteBalance(e))}
onPointerDown={(e) => {
if (localMode) startLocalMask(e);
else if (healMode) startHeal(e);