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
+641 -70
View File
@@ -1,6 +1,6 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { ASPECTS, BW_FILTERS, HUE_BANDS, identityCurve } from '../lib/edits';
import { computeAutoEdits } from '../lib/auto';
import { ASPECTS, BW_FILTERS, HUE_BANDS, identityCurve, MAX_LOCAL_LAYERS } from '../lib/edits';
import { computeAutoEdits, computeAutoWhiteBalance } from '../lib/auto';
import { autoNoiseFor } from '../lib/noiseProfile';
import { clearDenoised, getDenoiseJob, startDenoise } from '../lib/api';
import { clamp } from '../lib/curves';
@@ -19,7 +19,10 @@ import type {
import CurveEditor from './CurveEditor';
import { getBitmap } from '../lib/images';
import { grainSampleWindow, rotatedBounds, Renderer } from '../gl/renderer';
import { applyFilmVariant, FILM_VARIANTS, type FilmVariant } from '../lib/presets';
import { applyFilmVariant, FILM_VARIANTS, PRESET_CATEGORIES, type FilmVariant } from '../lib/presets';
import { usePersistentState } from '../lib/usePersistentState';
import { loadProofProfile, setActiveProofCube, type SoftProofCube } from '../lib/softProof';
import { dcpRgbCam, parseDcp } from '../lib/dcp';
import { usePresetThumbs } from './PresetThumbs';
import { availableFor, findLensForMeta, searchLens, type LensSearchResult } from '../lib/lensfun';
import {
@@ -74,6 +77,7 @@ export function BasicPanel({
onPicker,
}: PanelSetProps & { picker?: boolean; onPicker?: (active: boolean) => void }) {
const [autoBusy, setAutoBusy] = useState(false);
const [wbBusy, setWbBusy] = useState(false);
const auto = async () => {
setAutoBusy(true);
@@ -85,6 +89,15 @@ export function BasicPanel({
}
};
const autoWb = async () => {
setWbBusy(true);
try {
set(await computeAutoWhiteBalance(photo.thumb), 'Auto white balance');
} finally {
setWbBusy(false);
}
};
return (
<Panel title="Light">
<div className="subhead">
@@ -98,17 +111,41 @@ export function BasicPanel({
>
{picker ? 'Picking…' : 'Eyedropper'}
</button>
<button className="link-btn" onClick={() => set({ temp: 0, tint: 0 }, 'As shot')}>
<button className="link-btn" onClick={() => void autoWb()} disabled={wbBusy}>
{wbBusy ? 'Reading…' : 'Auto WB'}
</button>
<button className="link-btn" onClick={() => set({ temp: 0, tint: 0, kelvin: null }, 'As shot')}>
As shot
</button>
</div>
</div>
<Slider
label="Temp"
value={edits.temp}
onChange={(v) => set({ temp: v }, 'Temperature')}
track="linear-gradient(90deg,#3f74d8,#a8b6c6,#f4b23f)"
/>
<label className="check-row">
<input
type="checkbox"
checked={edits.kelvin != null}
onChange={(e) => set({ kelvin: e.target.checked ? 5500 : null }, 'Kelvin white balance')}
/>
Absolute Kelvin (5500 K reference)
</label>
{edits.kelvin == null ? (
<Slider
label="Temp"
value={edits.temp}
onChange={(v) => set({ temp: v }, 'Temperature')}
track="linear-gradient(90deg,#3f74d8,#a8b6c6,#f4b23f)"
/>
) : (
<Slider
label="Temperature"
min={1500}
max={12000}
step={50}
value={edits.kelvin}
onChange={(v) => set({ kelvin: v }, 'Kelvin temperature')}
format={(v) => `${Math.round(v)} K`}
track="linear-gradient(90deg,#3f74d8,#a8b6c6,#f4b23f)"
/>
)}
<Slider
label="Tint"
value={edits.tint}
@@ -154,6 +191,14 @@ export function BasicPanel({
<Slider label="Dehaze" value={edits.dehaze} onChange={(v) => set({ dehaze: v }, 'Dehaze')} />
<Slider label="Vibrance" value={edits.vibrance} onChange={(v) => set({ vibrance: v }, 'Vibrance')} />
<Slider label="Saturation" value={edits.saturation} onChange={(v) => set({ saturation: v }, 'Saturation')} />
<Slider
label="Redscale"
min={0}
max={100}
value={edits.redscale}
onChange={(v) => set({ redscale: v }, 'Redscale')}
track="linear-gradient(90deg,#a8b6c6,#d96b34,#8f1d12)"
/>
<label className="toggle">
<input type="checkbox" checked={edits.bw} onChange={(e) => set({ bw: e.target.checked }, 'Black & white')} />
@@ -214,7 +259,11 @@ export function CurvePanel({ edits, set }: PanelSetProps) {
className="link-btn"
onClick={() =>
set(
{ curve: { ...edits.curve, [channel]: identityCurve() }, parametric: { highlights: 0, lights: 0, darks: 0, blacks: 0 } },
{
curve: { ...edits.curve, [channel]: identityCurve() },
levels: { black: 0, white: 100, gamma: 1 },
parametric: { highlights: 0, lights: 0, darks: 0, blacks: 0 },
},
'Reset tone curve',
)
}
@@ -223,6 +272,39 @@ export function CurvePanel({ edits, set }: PanelSetProps) {
</button>
}
>
<div className="subhead">
<span>Input levels</span>
</div>
<Slider
label="Black point"
min={0}
max={45}
value={edits.levels.black}
onChange={(v) =>
set({ levels: { ...edits.levels, black: Math.min(v, edits.levels.white - 5) } }, 'Black point')
}
format={(v) => `${Math.round(v)}`}
/>
<Slider
label="White point"
min={55}
max={100}
value={edits.levels.white}
onChange={(v) =>
set({ levels: { ...edits.levels, white: Math.max(v, edits.levels.black + 5) } }, 'White point')
}
format={(v) => `${Math.round(v)}`}
/>
<Slider
label="Gamma"
min={0.3}
max={3}
step={0.05}
value={edits.levels.gamma}
onChange={(v) => set({ levels: { ...edits.levels, gamma: v } }, 'Midtone gamma')}
format={(v) => v.toFixed(2)}
def={1}
/>
<div className="tabs">
{(['rgb', 'red', 'green', 'blue'] as CurveChannel[]).map((c) => (
<button key={c} className={`tab ${channel === c ? 'on' : ''}`} onClick={() => setChannel(c)}>
@@ -230,7 +312,18 @@ export function CurvePanel({ edits, set }: PanelSetProps) {
</button>
))}
</div>
<CurveEditor points={points} onChange={update} color={CURVE_COLORS[channel]} />
<CurveEditor
points={points}
onChange={update}
color={CURVE_COLORS[channel]}
parametric={edits.parametric}
onParametric={(key, value) =>
set(
{ parametric: { ...edits.parametric, [key]: value } },
`Parametric ${key}`,
)
}
/>
<div className="subhead">
<span>Parametric</span>
</div>
@@ -689,36 +782,210 @@ export function DetailPanel({ edits, photo, set }: PanelSetProps) {
);
}
const BRAND_PREFIX = /^(Kodak|Fujifilm|Ilford|Agfa|CineStill|Lomography) /;
const ALL = 'All';
const FAVOURITES = 'Favourites';
const MY_PRESETS = 'My presets';
function presetCategory(preset: Preset): string {
if (preset.custom || preset.group === 'User presets') return MY_PRESETS;
return preset.category ?? 'Essentials';
}
/** Film tiles drop the brand, since the group header already names it. */
function shortName(preset: Preset): string {
if (!preset.film) return preset.name;
const prefix = `${preset.group} `;
return preset.name.startsWith(prefix) ? preset.name.slice(prefix.length) : preset.name;
}
const FILM_CATEGORIES = ['Colour Negative', 'Colour Slide', 'Black & White', 'Cinema', 'Instant', 'Redscale', 'Experimental'];
/**
* Category picker for the preset browser. This is a plain menu rather than a
* native <select>: the browser popup tears down when the panel repaints while
* the preset thumbnails stream in, so it would close before you could pick.
*/
function PresetFilterMenu({
value,
onChange,
filmCats,
lookCats,
counts,
}: {
value: string;
onChange: (id: string) => void;
filmCats: { id: string; label: string; hint: string }[];
lookCats: { id: string; label: string; hint: string }[];
counts: Map<string, number>;
}) {
const [open, setOpen] = useState(false);
const root = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const onPointerDown = (event: PointerEvent) => {
if (root.current && event.target instanceof Node && root.current.contains(event.target)) return;
setOpen(false);
};
const onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape') setOpen(false);
};
window.addEventListener('pointerdown', onPointerDown, true);
window.addEventListener('keydown', onKeyDown, true);
return () => {
window.removeEventListener('pointerdown', onPointerDown, true);
window.removeEventListener('keydown', onKeyDown, true);
};
}, [open]);
const labelOf = (id: string) => {
if (id === ALL) return 'All';
if (id === FAVOURITES) return 'Favourites';
if (id === MY_PRESETS) return 'My presets';
return PRESET_CATEGORIES.find((category) => category.id === id)?.label ?? id;
};
const pick = (id: string) => {
onChange(id);
setOpen(false);
};
const item = (id: string, text: string, hint?: string) => (
<button
key={id}
type="button"
role="option"
aria-selected={id === value}
className={`preset-menu-item ${id === value ? 'on' : ''}`}
title={hint}
onClick={() => pick(id)}
>
<span className="preset-menu-label">{text}</span>
<span className="preset-menu-count">{counts.get(id) ?? 0}</span>
</button>
);
return (
<div className="preset-filter" ref={root}>
<button
type="button"
className="preset-select"
aria-label="Preset category"
aria-haspopup="listbox"
aria-expanded={open}
onClick={() => setOpen((prev) => !prev)}
>
<span className="preset-select-text">{labelOf(value)}</span>
<span className="preset-select-chev" aria-hidden="true">
▾
</span>
</button>
{open && (
<div className="preset-menu" role="listbox" aria-label="Preset category">
{item(ALL, 'All')}
{item(FAVOURITES, '★ Favourites')}
{(counts.get(MY_PRESETS) ?? 0) > 0 && item(MY_PRESETS, 'My presets')}
<div className="preset-menu-head">Film stocks</div>
{filmCats.map((category) => item(category.id, category.label, category.hint))}
{lookCats.length > 0 && <div className="preset-menu-head">Creative looks</div>}
{lookCats.map((category) => item(category.id, category.label, category.hint))}
</div>
)}
</div>
);
}
export function PresetsPanel({
presets,
photo,
onApply,
onSave,
onDelete,
}: {
presets: Preset[];
photo: PhotoRecord;
onApply: (preset: Preset) => void;
onSave: (name: string) => void;
onDelete?: (id: string) => void;
}) {
const [query, setQuery] = useState('');
const [filter, setFilter] = usePersistentState<string>('presets.filter', ALL);
const [favourites, setFavourites] = usePersistentState<string[]>('presets.favourites', []);
const [collapsed, setCollapsed] = useState<string[]>([]);
const [variant, setVariant] = useState<FilmVariant>('base');
// Variants are derived on the fly, so every stock gets push/pull and split
// grade versions without tripling the catalogue.
const shown = useMemo(() => presets.map((p) => applyFilmVariant(p, variant)), [presets, variant]);
const [focusedId, setFocusedId] = useState<string | null>(null);
const groups = new Map<string, Preset[]>();
for (const preset of shown) {
const arr = groups.get(preset.group) ?? [];
arr.push(preset);
groups.set(preset.group, arr);
}
const all = useMemo(
() => presets.map((preset) => ({ ...preset, category: presetCategory(preset) })),
[presets],
);
const counts = useMemo(() => {
const map = new Map<string, number>([[ALL, all.length]]);
for (const preset of all) {
map.set(preset.category!, (map.get(preset.category!) ?? 0) + 1);
} map.set(FAVOURITES, all.reduce((n, preset) => n + (favourites.includes(preset.id) ? 1 : 0), 0));
map.set(MY_PRESETS, all.reduce((n, preset) => n + (preset.category === MY_PRESETS ? 1 : 0), 0));
return map;
}, [all, favourites]);
// One compact picker instead of a wall of pills: film stocks and creative
// looks are separated, and empty categories stay out of the list.
const filmCats = useMemo(
() => PRESET_CATEGORIES.filter((category) => FILM_CATEGORIES.includes(category.id) && (counts.get(category.id) ?? 0) > 0),
[counts],
);
const lookCats = useMemo(
() => PRESET_CATEGORIES.filter((category) => !FILM_CATEGORIES.includes(category.id) && (counts.get(category.id) ?? 0) > 0),
[counts],
);
const validFilter =
filter === ALL || filter === FAVOURITES || filter === MY_PRESETS || (counts.get(filter) ?? 0) > 0 ? filter : ALL;
const filtered = useMemo(() => {
const q = query.trim().toLowerCase();
return all.filter((preset) => {
if (validFilter === FAVOURITES) {
if (!favourites.includes(preset.id)) return false;
} else if (validFilter !== ALL && preset.category !== validFilter) {
return false;
}
if (!q) return true;
return [preset.name, preset.group, preset.category, preset.description ?? '', ...(preset.tags ?? [])]
.join(' ')
.toLowerCase()
.includes(q);
});
}, [all, favourites, validFilter, query]);
// Variants are derived on the fly so every stock ships push/pull and split
// grade versions without multiplying the catalogue.
const shown = useMemo(() => filtered.map((preset) => applyFilmVariant(preset, variant)), [filtered, variant]);
const hasFilm = shown.some((preset) => preset.film);
const thumbs = usePresetThumbs(photo, shown);
const groups = useMemo(() => {
const map = new Map<string, Preset[]>();
for (const preset of shown) {
const arr = map.get(preset.group) ?? [];
arr.push(preset);
map.set(preset.group, arr);
}
return [...map.entries()];
}, [shown]);
const focused = shown.find((preset) => preset.id === focusedId) ?? null;
const starId = (preset: Preset) => (preset.film ? preset.id.split('::')[0] : preset.id);
const toggleFavourite = (id: string) =>
setFavourites((prev) => (prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id]));
const toggleGroup = (group: string) =>
setCollapsed((prev) => (prev.includes(group) ? prev.filter((item) => item !== group) : [...prev, group]));
return (
<div className="panel-stack">
<div className="panel-stack preset-browser">
<div className="dev-panel-head">
<span>Presets</span>
<span className="muted small">{shown.length}</span>
<button
className="icon-btn"
title="Save current settings as a preset"
@@ -730,43 +997,131 @@ export function PresetsPanel({
+
</button>
</div>
<div className="variant-row">
{FILM_VARIANTS.map((v) => (
<button
key={v.id}
className={`variant-btn ${variant === v.id ? 'on' : ''}`}
title={v.hint}
onClick={() => setVariant(v.id)}
>
{v.label}
</button>
))}
</div>
{[...groups.entries()].map(([group, items]) => (
<div key={group} className="preset-group">
<div className="preset-group-name">{group}</div>
<div className="preset-grid">
{items.map((preset) => {
const src = thumbs[preset.id];
return (
<button
key={preset.id}
className="preset-tile"
onClick={() => onApply(preset)}
title={`${preset.name}${src ? '' : ' — rendering preview…'}`}
>
{src ? (
<img src={src} alt={preset.name} loading="lazy" draggable={false} />
) : (
<span className="preset-tile-blank" />
)}
<span className="preset-tile-name">{preset.name.replace(BRAND_PREFIX, '')}</span>
</button>
);
})}
</div>
<div className="preset-toolbar">
<div className="preset-search">
<input
value={query}
placeholder="Search film, brand or tag…"
aria-label="Search presets"
onChange={(event) => setQuery(event.target.value)}
onKeyDown={(event) => {
if (event.key === 'Escape') setQuery('');
}}
/>
{query && (
<button className="preset-search-clear" aria-label="Clear search" onClick={() => setQuery('')}>
×
</button>
)}
</div>
))}
<PresetFilterMenu
value={validFilter}
onChange={setFilter}
filmCats={filmCats}
lookCats={lookCats}
counts={counts}
/>
</div>
{hasFilm && (
<div className="variant-row">
{FILM_VARIANTS.map((v) => (
<button
key={v.id}
className={`variant-btn ${variant === v.id ? 'on' : ''}`}
title={v.hint}
onClick={() => setVariant(v.id)}
>
{v.label}
</button>
))}
</div>
)}
<div className="preset-list">
{!shown.length && (
<div className="preset-empty">
{validFilter === FAVOURITES
? 'No favourites yet — hover a preset and click the star.'
: 'No presets match this search.'}
</div>
)}
{groups.map(([group, items]) => {
const isCollapsed = collapsed.includes(group);
return (
<div key={group} className="preset-group">
<button
className="preset-group-head"
aria-expanded={!isCollapsed}
onClick={() => toggleGroup(group)}
>
<span>{group}</span>
<span className="preset-group-count">{items.length}</span>
<span className="preset-group-chev">{isCollapsed ? '▸' : '▾'}</span>
</button>
{!isCollapsed && (
<div className="preset-grid">
{items.map((preset) => {
const src = thumbs[preset.id];
const favourite = favourites.includes(starId(preset));
return (
<div key={preset.id} className="preset-tile-wrap">
<button
className="preset-tile"
onClick={() => onApply(preset)}
onMouseEnter={() => setFocusedId(preset.id)}
onFocus={() => setFocusedId(preset.id)}
title={`${preset.name}${src ? '' : ' — rendering preview…'}`}
>
{src ? (
<img src={src} alt={preset.name} loading="lazy" draggable={false} />
) : (
<span className="preset-tile-blank" />
)}
<span className="preset-tile-name">{shortName(preset)}</span>
</button>
<button
className={`preset-star ${favourite ? 'on' : ''}`}
aria-label={favourite ? `Unstar ${preset.name}` : `Star ${preset.name}`}
aria-pressed={favourite}
onClick={() => toggleFavourite(starId(preset))}
>
★
</button>
{onDelete && presetCategory(preset) === MY_PRESETS && (
<button
className="preset-del"
aria-label={`Delete ${preset.name}`}
title="Delete preset"
onClick={() => {
if (window.confirm(`Delete preset “${preset.name}”?`)) onDelete(preset.id);
}}
>
×
</button>
)}
</div>
);
})}
</div>
)}
</div>
);
})}
</div>
{focused && (
<div className="preset-detail">
<strong>{focused.name}</strong>
{focused.description && <span>{focused.description}</span>}
<span className="preset-detail-meta">
{[focused.film?.process, focused.film?.speed ? `ISO ${focused.film.speed}` : null, focused.group]
.filter(Boolean)
.join(' · ')}
</span>
</div>
)}
</div>
);
}
@@ -1130,6 +1485,7 @@ export function LocalPanel({
onPasteLayer,
canPaste,
onAutoMask,
onSampleRange,
autoBusy,
}: PanelSetProps & {
activeId: string | null;
@@ -1145,6 +1501,8 @@ export function LocalPanel({
onPasteLayer: () => void;
canPaste: boolean;
onAutoMask: (kind: 'subject' | 'sky' | 'background') => void;
/** Arms the canvas click that samples a colour range for the active layer. */
onSampleRange: () => void;
autoBusy?: boolean;
}) {
const layers = edits.local ?? [];
@@ -1160,26 +1518,26 @@ export function LocalPanel({
active && patch({ range: { ...active.range, [key]: value } }, 'Local range');
return (
<Panel title="Local adjustments" right={<span className="muted small">{layers.length}/4</span>}>
<Panel title="Local adjustments" right={<span className="muted small">{layers.length}/{MAX_LOCAL_LAYERS}</span>}>
<div className="btn-row local-add">
<button className="btn ghost small" onClick={() => onAdd('brush')} disabled={layers.length >= 4}>
<button className="btn ghost small" onClick={() => onAdd('brush')} disabled={layers.length >= MAX_LOCAL_LAYERS}>
{LOCAL_ICON.brush} Brush
</button>
<button className="btn ghost small" onClick={() => onAdd('linear')} disabled={layers.length >= 4}>
<button className="btn ghost small" onClick={() => onAdd('linear')} disabled={layers.length >= MAX_LOCAL_LAYERS}>
{LOCAL_ICON.linear} Linear
</button>
<button className="btn ghost small" onClick={() => onAdd('radial')} disabled={layers.length >= 4}>
<button className="btn ghost small" onClick={() => onAdd('radial')} disabled={layers.length >= MAX_LOCAL_LAYERS}>
{LOCAL_ICON.radial} Radial
</button>
</div>
<div className="btn-row local-add auto-mask-row">
<button className="btn ghost small" onClick={() => onAutoMask('subject')} disabled={layers.length >= 4 || autoBusy}>
<button className="btn ghost small" onClick={() => onAutoMask('subject')} disabled={layers.length >= MAX_LOCAL_LAYERS || autoBusy}>
{autoBusy ? '…' : '✦'} Subject
</button>
<button className="btn ghost small" onClick={() => onAutoMask('sky')} disabled={layers.length >= 4 || autoBusy}>
<button className="btn ghost small" onClick={() => onAutoMask('sky')} disabled={layers.length >= MAX_LOCAL_LAYERS || autoBusy}>
{autoBusy ? '…' : '✦'} Sky
</button>
<button className="btn ghost small" onClick={() => onAutoMask('background')} disabled={layers.length >= 4 || autoBusy}>
<button className="btn ghost small" onClick={() => onAutoMask('background')} disabled={layers.length >= MAX_LOCAL_LAYERS || autoBusy}>
{autoBusy ? '…' : '✦'} Background
</button>
</div>
@@ -1195,7 +1553,7 @@ export function LocalPanel({
<button
className="btn ghost small"
onClick={onPasteLayer}
disabled={!canPaste || layers.length >= 4}
disabled={!canPaste || layers.length >= MAX_LOCAL_LAYERS}
title="Paste the copied mask into this photo"
>
Paste mask
@@ -1234,7 +1592,7 @@ export function LocalPanel({
>
{maskMode ? 'Done mask' : 'Edit mask'}
</button>
<button className="btn ghost small" onClick={() => onDuplicate(active.id)} disabled={layers.length >= 4}>
<button className="btn ghost small" onClick={() => onDuplicate(active.id)} disabled={layers.length >= MAX_LOCAL_LAYERS}>
Duplicate
</button>
<button className="btn ghost small danger" onClick={() => onDelete(active.id)}>
@@ -1272,6 +1630,26 @@ export function LocalPanel({
/>
)}
<div className="local-subhead">Combine</div>
<div className="btn-row local-modes">
{(['add', 'subtract', 'intersect'] as const).map((mode) => (
<button
key={mode}
className={`chip tiny ${active.mode === mode ? 'on' : ''}`}
title={
mode === 'add'
? 'Apply this adjustment inside the mask'
: mode === 'subtract'
? 'Apply it outside this mask, within the layer above'
: 'Apply it only where this mask overlaps the layer above'
}
onClick={() => patch({ mode }, `Mask ${mode}`)}
>
{mode === 'add' ? 'Add' : mode === 'subtract' ? 'Subtract' : 'Intersect'}
</button>
))}
</div>
<div className="local-subhead">Light</div>
<Slider
label="Exposure"
@@ -1297,6 +1675,38 @@ export function LocalPanel({
value={active.adjust.shadows}
onChange={(v) => adjust('shadows', v)}
/>
<Slider
label="Whites"
value={active.adjust.whites}
onChange={(v) => adjust('whites', v)}
/>
<Slider
label="Blacks"
value={active.adjust.blacks}
onChange={(v) => adjust('blacks', v)}
/>
<div className="local-subhead">Detail</div>
<Slider
label="Texture"
value={active.adjust.texture}
onChange={(v) => adjust('texture', v)}
/>
<Slider
label="Clarity"
value={active.adjust.clarity}
onChange={(v) => adjust('clarity', v)}
/>
<Slider
label="Dehaze"
value={active.adjust.dehaze}
onChange={(v) => adjust('dehaze', v)}
/>
<Slider
label="Sharpen"
value={active.adjust.sharpen}
onChange={(v) => adjust('sharpen', v)}
/>
<div className="local-subhead">Colour</div>
<Slider
@@ -1311,9 +1721,30 @@ export function LocalPanel({
value={active.adjust.saturation}
onChange={(v) => adjust('saturation', v)}
/>
<Slider
label="Vibrance"
value={active.adjust.vibrance}
onChange={(v) => adjust('vibrance', v)}
/>
<Slider
label="Hue shift"
min={-180}
max={180}
value={active.adjust.hue}
onChange={(v) => adjust('hue', v)}
format={(v) => `${v > 0 ? '+' : ''}${Math.round(v)}°`}
track={HUE_TRACK}
/>
<div className="local-subhead">
Range
<button
className="chip tiny"
onClick={onSampleRange}
title="Click a colour in the photo to limit this mask to similar hues"
>
Sample
</button>
<button
className={`chip tiny ${active.range.enabled ? 'on' : ''}`}
onClick={() => range('enabled', !active.range.enabled)}
@@ -1380,9 +1811,17 @@ export function LocalPanel({
contrast: 0,
highlights: 0,
shadows: 0,
whites: 0,
blacks: 0,
temp: 0,
tint: 0,
saturation: 0,
vibrance: 0,
hue: 0,
texture: 0,
clarity: 0,
dehaze: 0,
sharpen: 0,
},
range: { ...active.range, enabled: false },
},
@@ -1725,8 +2164,104 @@ export function OpticsPanel({
);
}
export function ProofPanel({ edits, set }: PanelSetProps) {
/**
* A DCP profile supplies the same XYZ-to-camera matrix the body writes into a
* raw. Only the derived camera-to-sRGB matrix is stored in the edit: the profile
* file itself is not kept, so a photo stays self-contained and the choice
* round-trips through presets and XMP like any other setting.
*/
export function CameraProfilePanel({
edits,
photo,
set,
cameraNative = false,
}: PanelSetProps & { cameraNative?: boolean }) {
const [error, setError] = useState<string | null>(null);
const profile = edits.cameraProfile;
const load = async (file: File) => {
if (!cameraNative) return;
try {
const parsed = parseDcp(new Uint8Array(await file.arrayBuffer()));
if (!parsed) throw new Error('That file is not a DCP camera profile');
const matrix = dcpRgbCam(parsed);
if (!matrix) throw new Error('This profile has no usable colour matrix');
setError(null);
set({ cameraProfile: { name: parsed.name, matrix } }, 'Camera profile');
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not read that profile');
}
};
// Camera profiles describe raw sensor data; a JPEG has already been through
// the body's converter, so the panel would have nothing to act on.
if (!photo.raw) return null;
return (
<Panel title="Camera profile" defaultOpen={false}>
{cameraNative && (
<div className="btn-row">
<label className="btn ghost small">
{profile ? 'Replace DCP profile' : 'Load DCP profile'}
<input
type="file"
accept=".dcp"
hidden
onChange={(e) => {
const file = e.target.files?.[0];
if (file) void load(file);
e.target.value = '';
}}
/>
</label>
{profile && (
<button
className="btn ghost small"
onClick={() => {
setError(null);
set({ cameraProfile: null }, 'Body camera profile');
}}
>
Use body matrix
</button>
)}
</div>
)}
<p className="muted small panel-hint">
{!cameraNative
? 'This proxy was decoded straight to sRGB, so there are no camera samples to profile. Reprocess the RAW to enable camera profiles.'
: profile
? `Rendering through ${profile.name}.`
: 'Rendering with the matrix stored in the raw. Load a .dcp to render through a different camera profile.'}
</p>
{error && <p className="muted small panel-hint">{error}</p>}
</Panel>
);
}
export function ProofPanel({
edits,
set,
proofProfile,
onProofProfile,
}: PanelSetProps & {
/** Name of the printer profile loaded for this session, if any. */
proofProfile?: string | null;
onProofProfile?: (cube: SoftProofCube | null) => void;
}) {
const proof = edits.proof;
const [profileError, setProfileError] = useState<string | null>(null);
const loadProfile = async (file: File) => {
try {
const cube = loadProofProfile(new Uint8Array(await file.arrayBuffer()));
setProfileError(null);
onProofProfile?.(cube);
} catch (err) {
setProfileError(err instanceof Error ? err.message : 'Could not read that profile');
}
};
return (
<Panel title="Soft proofing" defaultOpen={false}>
<div className="btn-row">
@@ -1767,8 +2302,44 @@ export function ProofPanel({ edits, set }: PanelSetProps) {
format={(v) => `${Math.round(v)}%`}
def={2}
/>
<div className="subhead">
<span>Printer profile</span>
</div>
<div className="btn-row">
<label className="btn ghost small">
{proofProfile ? 'Replace ICC profile' : 'Load ICC profile'}
<input
type="file"
accept=".icc,.icm,application/vnd.iccprofile"
hidden
onChange={(e) => {
const file = e.target.files?.[0];
if (file) void loadProfile(file);
e.target.value = '';
}}
/>
</label>
{proofProfile && (
<button
className="btn ghost small"
onClick={() => {
setActiveProofCube(null);
setProfileError(null);
onProofProfile?.(null);
}}
>
Use paper simulation
</button>
)}
</div>
<p className="muted small panel-hint">
Paper white, black point and a print-gamut preview are applied to the canvas and export. Turn off before delivering screen files.
{proofProfile
? `Proofing through ${proofProfile}: the canvas and exports show what this printer can reproduce.`
: 'Load a printer .icc/.icm to prove through its real A2B/B2A tables. Without one, the paper controls are an approximation.'}
</p>
{profileError && <p className="muted small panel-hint">{profileError}</p>}
<p className="muted small panel-hint">
Turn proofing off before delivering screen files.
</p>
</Panel>
);