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:
@@ -0,0 +1,248 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { analyseGrey, greyFromPixels, groupDuplicates, sharpnessGrade } from '../lib/cull';
|
||||
import type { CullStats } from '../lib/cull';
|
||||
import type { PhotoRecord } from '../types';
|
||||
|
||||
interface Row {
|
||||
photo: PhotoRecord;
|
||||
stats: CullStats | null;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
photos: PhotoRecord[];
|
||||
onReject: (ids: string[]) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const THUMB_EDGE = 96;
|
||||
|
||||
async function statsFor(photo: PhotoRecord): Promise<CullStats> {
|
||||
const src = photo.thumbUrl ?? photo.thumb;
|
||||
const image = new Image();
|
||||
image.decoding = 'async';
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
image.onload = () => resolve();
|
||||
image.onerror = () => reject(new Error('Could not read the thumbnail'));
|
||||
image.src = src;
|
||||
});
|
||||
const width = THUMB_EDGE;
|
||||
const height = Math.max(24, Math.round((width * image.naturalHeight) / Math.max(1, image.naturalWidth)));
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
if (!ctx) throw new Error('Could not analyse the thumbnail');
|
||||
ctx.drawImage(image, 0, 0, width, height);
|
||||
return analyseGrey(greyFromPixels(ctx.getImageData(0, 0, width, height).data), width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus and duplicate pass over a selection, run on the thumbnails the grid
|
||||
* already loaded. It never edits or rates anything by itself: the owner sees
|
||||
* the scores and chooses what to reject.
|
||||
*/
|
||||
export default function CullAssistModal({ photos, onReject, onClose }: Props) {
|
||||
const [rows, setRows] = useState<Row[]>([]);
|
||||
const [done, setDone] = useState(0);
|
||||
const [running, setRunning] = useState(true);
|
||||
const [current, setCurrent] = useState('');
|
||||
const [threshold, setThreshold] = useState(22);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const next: Row[] = photos.map((photo) => ({ photo, stats: null }));
|
||||
setRows(next.map((row) => ({ ...row })));
|
||||
setDone(0);
|
||||
setRunning(true);
|
||||
|
||||
void (async () => {
|
||||
for (let i = 0; i < next.length; i++) {
|
||||
if (cancelled) return;
|
||||
setCurrent(next[i].photo.name);
|
||||
try {
|
||||
next[i] = { ...next[i], stats: await statsFor(next[i].photo) };
|
||||
} catch (err) {
|
||||
next[i] = {
|
||||
...next[i],
|
||||
error: err instanceof Error ? err.message : 'Analysis failed',
|
||||
};
|
||||
}
|
||||
if (cancelled) return;
|
||||
setRows(next.map((row) => ({ ...row })));
|
||||
setDone(i + 1);
|
||||
}
|
||||
if (!cancelled) {
|
||||
setRunning(false);
|
||||
setCurrent('');
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [photos]);
|
||||
|
||||
const analysed = rows.filter((row) => row.stats);
|
||||
const soft = analysed.filter((row) => (row.stats?.sharpness ?? 100) < threshold);
|
||||
const duplicates = useMemo(
|
||||
() =>
|
||||
groupDuplicates(
|
||||
analysed.map((row) => ({ ...row, hash: row.stats?.hash ?? '' })),
|
||||
9,
|
||||
),
|
||||
[analysed],
|
||||
);
|
||||
const duplicateRejects = useMemo(() => {
|
||||
const ids: string[] = [];
|
||||
for (const group of duplicates) {
|
||||
// Keep the sharpest frame of the burst; everything close to it is the
|
||||
// alternative the photographer would otherwise have to compare by eye.
|
||||
const sorted = [...group].sort(
|
||||
(a, b) => (b.stats?.sharpness ?? 0) - (a.stats?.sharpness ?? 0),
|
||||
);
|
||||
for (const row of sorted.slice(1)) ids.push(row.photo.id);
|
||||
}
|
||||
return ids;
|
||||
}, [duplicates]);
|
||||
|
||||
const pct = photos.length ? Math.round((done / photos.length) * 100) : 0;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="modal-backdrop"
|
||||
onPointerDown={(e) => e.target === e.currentTarget && !running && onClose()}
|
||||
>
|
||||
<div className="modal raw-modal cull-modal" role="dialog" aria-modal="true" aria-label="Cull assist">
|
||||
<header className="modal-head">
|
||||
<div>
|
||||
<h2>Cull assist</h2>
|
||||
<p className="muted small">
|
||||
Focus and duplicate checks on {photos.length} photo{photos.length === 1 ? '' : 's'}.
|
||||
Nothing is rated or rejected without your say-so.
|
||||
</p>
|
||||
</div>
|
||||
{!running && (
|
||||
<button className="icon-btn" onClick={onClose} title="Close">
|
||||
×
|
||||
</button>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div className="modal-body">
|
||||
{running && (
|
||||
<>
|
||||
<div className="progress-bar">
|
||||
<div className="progress-fill" style={{ width: `${pct}%` }} />
|
||||
</div>
|
||||
<p className="muted small">
|
||||
{done} of {photos.length}
|
||||
{current ? ` · ${current}` : '…'}
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
|
||||
{!running && (
|
||||
<>
|
||||
<div className="cull-summary">
|
||||
<div>
|
||||
<strong>{soft.length}</strong>
|
||||
<span>soft under {threshold}</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>{duplicates.length}</strong>
|
||||
<span>duplicate set{duplicates.length === 1 ? '' : 's'}</span>
|
||||
</div>
|
||||
<div>
|
||||
<strong>{analysed.length}</strong>
|
||||
<span>analysed</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label className="cull-threshold">
|
||||
<span>Soft threshold</span>
|
||||
<input
|
||||
type="range"
|
||||
min={5}
|
||||
max={55}
|
||||
value={threshold}
|
||||
onChange={(e) => setThreshold(Number(e.target.value))}
|
||||
/>
|
||||
<span className="muted small">{threshold}</span>
|
||||
</label>
|
||||
|
||||
<ul className="cull-list">
|
||||
{[...analysed]
|
||||
.sort((a, b) => (a.stats?.sharpness ?? 0) - (b.stats?.sharpness ?? 0))
|
||||
.slice(0, 60)
|
||||
.map((row) => {
|
||||
const stats = row.stats as CullStats;
|
||||
const grade = sharpnessGrade(stats.sharpness);
|
||||
return (
|
||||
<li key={row.photo.id}>
|
||||
<span className="cull-name" title={row.photo.name}>
|
||||
{row.photo.name}
|
||||
</span>
|
||||
<span className={`cull-grade ${grade}`}>{grade}</span>
|
||||
<span className="cull-score">{stats.sharpness}</span>
|
||||
<span className="muted small">
|
||||
{stats.clippedHigh > 0.08
|
||||
? 'highlights clipped'
|
||||
: stats.clippedLow > 0.12
|
||||
? 'crushed shadows'
|
||||
: stats.mean < 30
|
||||
? 'very dark'
|
||||
: ''}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
{analysed.length > 60 && (
|
||||
<p className="muted small">Showing the 60 softest frames.</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer className="modal-foot">
|
||||
<span className="muted small">
|
||||
Scores come from the thumbnails, so treat them as a first pass.
|
||||
</span>
|
||||
{running ? (
|
||||
<button className="btn ghost" onClick={onClose}>
|
||||
Hide
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
<button
|
||||
className="btn ghost small"
|
||||
disabled={!duplicateRejects.length}
|
||||
onClick={() => {
|
||||
onReject(duplicateRejects);
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
Reject {duplicateRejects.length} duplicate alternative
|
||||
{duplicateRejects.length === 1 ? '' : 's'}
|
||||
</button>
|
||||
<button
|
||||
className="btn ghost small danger"
|
||||
disabled={!soft.length}
|
||||
onClick={() => {
|
||||
onReject(soft.map((row) => row.photo.id));
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
Reject {soft.length} soft
|
||||
</button>
|
||||
<button className="btn primary" onClick={onClose}>
|
||||
Done
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,16 +2,33 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { buildSampler, clamp01 } from '../lib/curves';
|
||||
import type { CurvePoint } from '../types';
|
||||
|
||||
export type ParametricKey = 'highlights' | 'lights' | 'darks' | 'blacks';
|
||||
|
||||
interface Props {
|
||||
points: CurvePoint[];
|
||||
onChange: (points: CurvePoint[]) => void;
|
||||
color: string;
|
||||
/** Region tone shaper values, shown as draggable dots on the curve. */
|
||||
parametric?: Record<ParametricKey, number>;
|
||||
onParametric?: (key: ParametricKey, value: number) => void;
|
||||
}
|
||||
|
||||
export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
/** Lightroom-scale zones: the four regions share the diagonal evenly. */
|
||||
const ZONES: { key: ParametricKey; label: string; x: number }[] = [
|
||||
{ key: 'highlights', label: 'Highlights', x: 0.875 },
|
||||
{ key: 'lights', label: 'Lights', x: 0.625 },
|
||||
{ key: 'darks', label: 'Darks', x: 0.375 },
|
||||
{ key: 'blacks', label: 'Blacks', x: 0.125 },
|
||||
];
|
||||
|
||||
/** Full slider travel moves a zone dot a quarter of the graph. */
|
||||
const ZONE_TRAVEL = 0.18;
|
||||
|
||||
export default function CurveEditor({ points, onChange, color, parametric, onParametric }: Props) {
|
||||
const svgRef = useRef<SVGSVGElement>(null);
|
||||
const pointsRef = useRef(points);
|
||||
const [drag, setDrag] = useState<number | null>(null);
|
||||
const [paramDrag, setParamDrag] = useState<ParametricKey | null>(null);
|
||||
const [hover, setHover] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,6 +59,12 @@ export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
|
||||
const handleDown = (e: React.PointerEvent<SVGSVGElement>) => {
|
||||
e.preventDefault();
|
||||
const paramAttr = (e.target as Element).getAttribute('data-param');
|
||||
if (paramAttr && parametric && onParametric) {
|
||||
setParamDrag(paramAttr as ParametricKey);
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
return;
|
||||
}
|
||||
const idxAttr = (e.target as Element).getAttribute('data-idx');
|
||||
let idx: number;
|
||||
if (idxAttr !== null) {
|
||||
@@ -57,6 +80,15 @@ export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
};
|
||||
|
||||
const handleMove = (e: React.PointerEvent<SVGSVGElement>) => {
|
||||
if (paramDrag && parametric && onParametric) {
|
||||
const zone = ZONES.find((item) => item.key === paramDrag);
|
||||
if (!zone) return;
|
||||
const p = toNorm(e.clientX, e.clientY);
|
||||
const base = sampler(zone.x);
|
||||
const value = ((p.y - base) / ZONE_TRAVEL) * 100;
|
||||
onParametric(paramDrag, Math.round(Math.max(-100, Math.min(100, value))));
|
||||
return;
|
||||
}
|
||||
if (drag === null) return;
|
||||
const pts = pointsRef.current;
|
||||
const idx = drag;
|
||||
@@ -68,7 +100,10 @@ export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
onChange(next);
|
||||
};
|
||||
|
||||
const handleUp = () => setDrag(null);
|
||||
const handleUp = () => {
|
||||
setDrag(null);
|
||||
setParamDrag(null);
|
||||
};
|
||||
|
||||
const removePoint = (idx: number) => {
|
||||
const pts = pointsRef.current;
|
||||
@@ -101,6 +136,37 @@ export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
</g>
|
||||
))}
|
||||
<line x1="0" y1="100" x2="100" y2="0" className="curve-diag" />
|
||||
{parametric &&
|
||||
onParametric &&
|
||||
ZONES.map((zone) => {
|
||||
const value = parametric[zone.key] ?? 0;
|
||||
const y = clamp01(sampler(zone.x) + (value / 100) * ZONE_TRAVEL);
|
||||
return (
|
||||
<g key={zone.key} style={{ cursor: 'ns-resize' }}>
|
||||
<line
|
||||
x1={zone.x * 100}
|
||||
y1="0"
|
||||
x2={zone.x * 100}
|
||||
y2="100"
|
||||
stroke="rgba(255,255,255,0.12)"
|
||||
strokeDasharray="2 3"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<circle
|
||||
data-param={zone.key}
|
||||
cx={zone.x * 100}
|
||||
cy={(1 - y) * 100}
|
||||
r={paramDrag === zone.key ? 3.2 : 2.3}
|
||||
fill="#141416"
|
||||
stroke="#f0c86a"
|
||||
strokeWidth="1.4"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
>
|
||||
<title>{`${zone.label}: ${value > 0 ? '+' : ''}${value}`}</title>
|
||||
</circle>
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
<path d={path} fill="none" stroke={color} strokeWidth="1.6" vectorEffect="non-scaling-stroke" />
|
||||
{points.map((p, i) => (
|
||||
<circle
|
||||
@@ -116,7 +182,9 @@ export default function CurveEditor({ points, onChange, color }: Props) {
|
||||
/>
|
||||
))}
|
||||
</svg>
|
||||
<div className="curve-hint">Click to add a point · drag to shape · double-click a point to remove</div>
|
||||
<div className="curve-hint">
|
||||
Click to add a point · drag to shape · drag the four gold dots for highlights, lights, darks and blacks
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+147
-37
@@ -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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { memo, useEffect, useRef, useState } from 'react';
|
||||
import { thumbTransform } from '../lib/edits';
|
||||
import { useEditedThumb } from '../lib/editThumbs';
|
||||
import type { PhotoRecord } from '../types';
|
||||
@@ -19,7 +19,7 @@ interface Props {
|
||||
* server/import thumbnail and the CSS orientation transform. Rendering starts
|
||||
* only when the tile is close to the viewport.
|
||||
*/
|
||||
export default function EditedImage({
|
||||
function EditedImage({
|
||||
photo,
|
||||
boxAspect = 4 / 3,
|
||||
alt,
|
||||
@@ -62,3 +62,9 @@ export default function EditedImage({
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Memoised: a selection change on the library re-renders the whole grid, and a
|
||||
* picture whose photo, size and props did not change has no work to redo.
|
||||
*/
|
||||
export default memo(EditedImage);
|
||||
|
||||
@@ -22,6 +22,10 @@ interface Props {
|
||||
onRename: (id: string, name: string) => void;
|
||||
onDelete: (id: string) => void;
|
||||
onSyncGallery?: (id: string) => void;
|
||||
onPublishGallery?: (id: string) => void;
|
||||
/** Server-backed account, so RAW originals can be re-decoded. */
|
||||
canReprocessRaw?: boolean;
|
||||
onReprocessEvent?: (id: string) => void;
|
||||
onReorderEvents: (dragId: string, targetId: string) => void;
|
||||
onDropPhotos: (ids: string[], eventId: string) => void;
|
||||
trashOpen: boolean;
|
||||
@@ -46,6 +50,9 @@ export default function EventSidebar({
|
||||
onRename,
|
||||
onDelete,
|
||||
onSyncGallery,
|
||||
onPublishGallery,
|
||||
canReprocessRaw = false,
|
||||
onReprocessEvent,
|
||||
onReorderEvents,
|
||||
onDropPhotos,
|
||||
trashOpen,
|
||||
@@ -63,6 +70,7 @@ export default function EventSidebar({
|
||||
const [dropTarget, setDropTarget] = useState<string | null>(null);
|
||||
|
||||
const counts = new Map<string, number>();
|
||||
const rawCounts = new Map<string, number>();
|
||||
let unsorted = 0;
|
||||
for (const p of photos) {
|
||||
if (!p.eventId) {
|
||||
@@ -70,6 +78,7 @@ export default function EventSidebar({
|
||||
continue;
|
||||
}
|
||||
counts.set(p.eventId, (counts.get(p.eventId) ?? 0) + 1);
|
||||
if (p.raw) rawCounts.set(p.eventId, (rawCounts.get(p.eventId) ?? 0) + 1);
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
@@ -250,15 +259,37 @@ export default function EventSidebar({
|
||||
<span className="event-count">{counts.get(event.id) ?? 0}</span>
|
||||
</button>
|
||||
<div className="event-tools">
|
||||
{immichEnabled && event.immich && onSyncGallery && (
|
||||
{canReprocessRaw && onReprocessEvent && (rawCounts.get(event.id) ?? 0) > 0 && (
|
||||
<button
|
||||
className="icon-btn"
|
||||
title="Push edits and originals to this event's Immich gallery"
|
||||
onClick={() => onSyncGallery(event.id)}
|
||||
title={`Reprocess ${rawCounts.get(event.id)} RAW file${
|
||||
rawCounts.get(event.id) === 1 ? '' : 's'
|
||||
} in this event`}
|
||||
onClick={() => onReprocessEvent(event.id)}
|
||||
>
|
||||
☁
|
||||
⟲
|
||||
</button>
|
||||
)}
|
||||
{immichEnabled &&
|
||||
(event.immich
|
||||
? onSyncGallery && (
|
||||
<button
|
||||
className="icon-btn"
|
||||
title="Publish new photos and edits to this event's Immich gallery"
|
||||
onClick={() => onSyncGallery(event.id)}
|
||||
>
|
||||
☁
|
||||
</button>
|
||||
)
|
||||
: onPublishGallery && (
|
||||
<button
|
||||
className="icon-btn"
|
||||
title="Create an Immich gallery for this event and publish its photos"
|
||||
onClick={() => onPublishGallery(event.id)}
|
||||
>
|
||||
☁+
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
className="icon-btn"
|
||||
title="Rename event"
|
||||
|
||||
@@ -5,6 +5,8 @@ import Slider from './Slider';
|
||||
import { getBitmap } from '../lib/images';
|
||||
import { frameToSource, grainCellPx, grainSampleWindow, outputSize, rotatedBounds, Renderer } from '../gl/renderer';
|
||||
import type { PhotoRecord } from '../types';
|
||||
import { COLOR_SPACE_OPTIONS } from '../lib/colorSpace';
|
||||
import type { OutputColorSpace } from '../lib/icc';
|
||||
|
||||
interface Props {
|
||||
photos: PhotoRecord[];
|
||||
@@ -280,8 +282,12 @@ export default function ExportModal({ photos, initial, recipes, onSaveRecipe, on
|
||||
value={opts.format}
|
||||
onChange={(e) => {
|
||||
const format = e.target.value as ExportFormat;
|
||||
const wide = format === 'jpeg' || format === 'tiff16';
|
||||
patch({
|
||||
format,
|
||||
// PNG/WebP output can carry converted pixels but no ICC tag, so
|
||||
// keep those formats in the tagged sRGB default.
|
||||
...(wide ? {} : { colorSpace: 'srgb' as OutputColorSpace }),
|
||||
// Watermarking needs an 8-bit canvas pass; keep the option off
|
||||
// rather than silently downgrading the 16-bit file.
|
||||
...(format === 'tiff16' ? { watermark: { ...opts.watermark, enabled: false } } : {}),
|
||||
@@ -435,6 +441,20 @@ export default function ExportModal({ photos, initial, recipes, onSaveRecipe, on
|
||||
<div className="subhead">
|
||||
<span>Output</span>
|
||||
</div>
|
||||
<label className="field">
|
||||
<span>Colour space</span>
|
||||
<select
|
||||
value={opts.colorSpace ?? 'srgb'}
|
||||
onChange={(e) => patch({ colorSpace: e.target.value as OutputColorSpace })}
|
||||
disabled={busy || (opts.format !== 'jpeg' && opts.format !== 'tiff16')}
|
||||
>
|
||||
{COLOR_SPACE_OPTIONS.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<Slider
|
||||
label="Output sharpening"
|
||||
min={0}
|
||||
@@ -460,7 +480,7 @@ export default function ExportModal({ photos, initial, recipes, onSaveRecipe, on
|
||||
onChange={(e) => patch({ embedProfile: e.target.checked })}
|
||||
disabled={opts.format === 'webp' || opts.format === 'png'}
|
||||
/>
|
||||
Embed sRGB profile (JPEG/TIFF)
|
||||
Embed {COLOR_SPACE_OPTIONS.find((option) => option.value === (opts.colorSpace ?? 'srgb'))?.label ?? 'sRGB'} profile (JPEG/TIFF)
|
||||
</label>
|
||||
|
||||
<div className="subhead">
|
||||
|
||||
@@ -291,8 +291,8 @@ export default function ImmichPanel({ onClose, onChanged, onToast }: Props) {
|
||||
</label>
|
||||
|
||||
<p className="muted small">
|
||||
Nothing is uploaded while you edit. Press the ☁ button on an event to push
|
||||
its edited photos and any originals Immich has not seen yet.
|
||||
Nothing is uploaded while you edit. Press ☁+ on an event to create its Immich
|
||||
gallery and publish it, or ☁ to push new photos and edits to an existing one.
|
||||
</p>
|
||||
|
||||
<label className="check-row">
|
||||
|
||||
@@ -24,6 +24,9 @@ interface Props {
|
||||
onStack: () => void;
|
||||
onVirtualCopy: () => void;
|
||||
onMerge: () => void;
|
||||
/** Re-decode the selected RAW files with the server's current pipeline. */
|
||||
onReprocessRaw?: () => void;
|
||||
reprocessBusy?: boolean;
|
||||
onPrint: () => void;
|
||||
stacks: Map<string, { count: number; expanded: boolean }>;
|
||||
onToggleStack: (id: string) => void;
|
||||
@@ -62,6 +65,8 @@ export default function LibraryGrid({
|
||||
onStack,
|
||||
onVirtualCopy,
|
||||
onMerge,
|
||||
onReprocessRaw,
|
||||
reprocessBusy = false,
|
||||
onPrint,
|
||||
stacks,
|
||||
onToggleStack,
|
||||
@@ -282,6 +287,16 @@ export default function LibraryGrid({
|
||||
<button className="btn ghost small" onClick={onMerge} disabled={selected.length < 2}>
|
||||
Merge
|
||||
</button>
|
||||
{onReprocessRaw && (
|
||||
<button
|
||||
className="btn ghost small"
|
||||
onClick={onReprocessRaw}
|
||||
disabled={reprocessBusy}
|
||||
title="Re-decode the selected RAW files with the current pipeline settings"
|
||||
>
|
||||
{reprocessBusy ? 'Reprocessing…' : 'Reprocess RAW'}
|
||||
</button>
|
||||
)}
|
||||
{onSendToImmich && (
|
||||
<button
|
||||
className="btn ghost small"
|
||||
|
||||
+641
-70
@@ -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>
|
||||
);
|
||||
|
||||
@@ -3,9 +3,11 @@ import {
|
||||
addGalleryComment,
|
||||
galleryDownloadAllUrl,
|
||||
galleryDownloadUrl,
|
||||
getGalleryStatus,
|
||||
loadGallery,
|
||||
setGalleryPick,
|
||||
setGalleryReview,
|
||||
unlockGallery,
|
||||
} from '../lib/api';
|
||||
import type { GalleryPayload, GalleryPhoto } from '../lib/api';
|
||||
|
||||
@@ -74,9 +76,22 @@ export default function ProofingGallery({ token }: { token: string }) {
|
||||
const [saving, setSaving] = useState<Set<string>>(new Set());
|
||||
const [commentDraft, setCommentDraft] = useState('');
|
||||
const [feedbackBusy, setFeedbackBusy] = useState(false);
|
||||
const [locked, setLocked] = useState(false);
|
||||
const [password, setPassword] = useState('');
|
||||
const [unlocking, setUnlocking] = useState(false);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
// The status call is what turns a locked link into a password prompt
|
||||
// instead of a dead end: the gallery body is a 401 while locked.
|
||||
const status = await getGalleryStatus(token);
|
||||
if (status.locked) {
|
||||
setLocked(true);
|
||||
setData(null);
|
||||
setFatal(null);
|
||||
return;
|
||||
}
|
||||
setLocked(false);
|
||||
const payload = await loadGallery(token, identity.current.id);
|
||||
setData(payload);
|
||||
setPicks(new Set(payload.photos.filter((p) => p.mine).map((p) => p.id)));
|
||||
@@ -103,6 +118,21 @@ export default function ProofingGallery({ token }: { token: string }) {
|
||||
};
|
||||
}, [data]);
|
||||
|
||||
const unlock = async () => {
|
||||
if (unlocking || !password) return;
|
||||
setUnlocking(true);
|
||||
setError(null);
|
||||
try {
|
||||
await unlockGallery(token, password);
|
||||
setPassword('');
|
||||
await load();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'That password did not work');
|
||||
} finally {
|
||||
setUnlocking(false);
|
||||
}
|
||||
};
|
||||
|
||||
const rememberName = (name: string) => {
|
||||
setClientName(name);
|
||||
try {
|
||||
@@ -260,6 +290,38 @@ export default function ProofingGallery({ token }: { token: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!data && locked) {
|
||||
return (
|
||||
<div className="proof">
|
||||
<div className="proof-splash proof-lock">
|
||||
<div className="logo large">Luminary</div>
|
||||
<h1>This gallery is private</h1>
|
||||
<p>Enter the password the photographer gave you.</p>
|
||||
<form
|
||||
className="proof-lock-form"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
void unlock();
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
autoFocus
|
||||
autoComplete="current-password"
|
||||
placeholder="Gallery password"
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
/>
|
||||
<button className="btn primary" type="submit" disabled={!password || unlocking}>
|
||||
{unlocking ? 'Opening…' : 'Open gallery'}
|
||||
</button>
|
||||
</form>
|
||||
{error && <p className="proof-subtle">{error}</p>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="proof">
|
||||
@@ -320,7 +382,7 @@ export default function ProofingGallery({ token }: { token: string }) {
|
||||
>
|
||||
My picks {pickedCount ? `(${pickedCount})` : ''}
|
||||
</button>
|
||||
{pickedCount > 0 && (
|
||||
{pickedCount > 0 && data.downloads?.allowed !== false && (
|
||||
<a
|
||||
className="btn ghost small"
|
||||
href={galleryDownloadAllUrl(token, identity.current.id)}
|
||||
@@ -419,9 +481,11 @@ export default function ProofingGallery({ token }: { token: string }) {
|
||||
<div className="proof-lb-bar">
|
||||
<div className="proof-lb-title">
|
||||
<span className="proof-lb-name">{lightboxPhoto.name}</span>
|
||||
<a className="btn ghost small" href={galleryDownloadUrl(token, lightboxPhoto.id)} download>
|
||||
Download
|
||||
</a>
|
||||
{data.downloads?.allowed !== false && (
|
||||
<a className="btn ghost small" href={galleryDownloadUrl(token, lightboxPhoto.id)} download>
|
||||
Download
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
className={`proof-lb-pick ${picks.has(lightboxPhoto.id) ? 'on' : ''}`}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
export interface RawReprocessFailure {
|
||||
name: string;
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface RawReprocessJob {
|
||||
running: boolean;
|
||||
/** Files attempted so far, including failures. */
|
||||
done: number;
|
||||
total: number;
|
||||
current: string;
|
||||
eventName?: string;
|
||||
failures: RawReprocessFailure[];
|
||||
cancelled?: boolean;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
job: RawReprocessJob;
|
||||
onCancel: () => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress and summary for a RAW re-decode run. The job keeps running while the
|
||||
* dialog is open; Cancel stops it after the file already in flight.
|
||||
*/
|
||||
export default function RawReprocessModal({ job, onCancel, onClose }: Props) {
|
||||
const succeeded = Math.max(0, job.done - job.failures.length);
|
||||
const pct = job.total ? Math.round((job.done / job.total) * 100) : 0;
|
||||
const scope = job.eventName ? `“${job.eventName}”` : 'the selection';
|
||||
|
||||
return (
|
||||
<div
|
||||
className="modal-backdrop"
|
||||
onPointerDown={(e) => e.target === e.currentTarget && !job.running && onClose()}
|
||||
>
|
||||
<div className="modal raw-modal" role="dialog" aria-modal="true" aria-label="RAW reprocess">
|
||||
<header className="modal-head">
|
||||
<div>
|
||||
<h2>{job.running ? 'Reprocessing RAW files' : 'RAW reprocess summary'}</h2>
|
||||
<p className="muted small">
|
||||
{job.total} RAW file{job.total === 1 ? '' : 's'} from {scope}. Existing edits and crops
|
||||
are kept.
|
||||
</p>
|
||||
</div>
|
||||
{!job.running && (
|
||||
<button className="icon-btn" onClick={onClose} title="Close">
|
||||
×
|
||||
</button>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div className="modal-body">
|
||||
<div className="progress-bar">
|
||||
<div className="progress-fill" style={{ width: `${pct}%` }} />
|
||||
</div>
|
||||
<p className="muted small">
|
||||
{job.running
|
||||
? job.cancelled
|
||||
? `Stopping after the current file · ${job.done} of ${job.total}`
|
||||
: `${job.done} of ${job.total}${job.current ? ` · ${job.current}` : '…'}`
|
||||
: job.cancelled
|
||||
? `Stopped after ${job.done} of ${job.total}. Reprocessed ${succeeded}.`
|
||||
: `Reprocessed ${succeeded} of ${job.total}.`}
|
||||
</p>
|
||||
|
||||
{!job.running && job.failures.length > 0 && (
|
||||
<div className="failures">
|
||||
<strong>
|
||||
{job.failures.length} file{job.failures.length === 1 ? '' : 's'} failed
|
||||
</strong>
|
||||
<ul>
|
||||
{job.failures.slice(0, 12).map((failure) => (
|
||||
<li key={failure.name}>
|
||||
{failure.name}: {failure.error}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{job.failures.length > 12 && (
|
||||
<p className="muted small">And {job.failures.length - 12} more…</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer className="modal-foot">
|
||||
{job.running ? (
|
||||
<>
|
||||
<span className="muted small">Cancel stops after the current file.</span>
|
||||
<button className="btn ghost danger" onClick={onCancel} disabled={job.cancelled}>
|
||||
{job.cancelled ? 'Stopping…' : 'Cancel'}
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<button className="btn primary" onClick={onClose}>
|
||||
Done
|
||||
</button>
|
||||
)}
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { createShare, getShare, pushProof, revokeShare } from '../lib/api';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { createShare, getShare, pushProof, revokeShare, saveShareSettings } from '../lib/api';
|
||||
import type { ShareState } from '../lib/api';
|
||||
import { DEFAULT_EXPORT, renderPhotoBlob } from '../lib/export';
|
||||
import type { ExportOptions } from '../lib/export';
|
||||
import type { PhotoRecord } from '../types';
|
||||
import { Renderer } from '../gl/renderer';
|
||||
|
||||
interface Props {
|
||||
event: { id: string; name: string };
|
||||
@@ -50,6 +51,13 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
const [published, setPublished] = useState(0);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [passwordDraft, setPasswordDraft] = useState('');
|
||||
const [expiryDraft, setExpiryDraft] = useState('');
|
||||
const [watermarkDraft, setWatermarkDraft] = useState('');
|
||||
const [downloadsOn, setDownloadsOn] = useState(true);
|
||||
const [capDraft, setCapDraft] = useState('0');
|
||||
const [savingSettings, setSavingSettings] = useState(false);
|
||||
const settingsLoaded = useRef(false);
|
||||
|
||||
const refresh = useCallback(async () => {
|
||||
try {
|
||||
@@ -93,15 +101,44 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
|
||||
const namesByPhoto = useMemo(() => new Map(photos.map((p) => [p.id, p.name])), [photos]);
|
||||
|
||||
const publishProofs = async () => {
|
||||
// Seeded once: the 20-second refresh must not overwrite fields being typed.
|
||||
useEffect(() => {
|
||||
const saved = share?.settings;
|
||||
if (!saved || settingsLoaded.current) return;
|
||||
settingsLoaded.current = true;
|
||||
setExpiryDraft(saved.expiresAt ? new Date(saved.expiresAt).toISOString().slice(0, 10) : '');
|
||||
setWatermarkDraft(saved.watermark ?? '');
|
||||
setDownloadsOn(saved.allowDownloads !== false);
|
||||
setCapDraft(String(saved.downloadCap || 0));
|
||||
}, [share]);
|
||||
|
||||
const publishProofs = async (watermark = share?.settings?.watermark ?? '') => {
|
||||
if (!photos.length || publishing) return 0;
|
||||
// The gallery watermark is baked into the published proof, so the
|
||||
// downloadable file carries it too — not just the on-screen overlay.
|
||||
const proofExport: ExportOptions = {
|
||||
...PROOF_EXPORT,
|
||||
watermark: {
|
||||
...PROOF_EXPORT.watermark,
|
||||
enabled: Boolean(watermark.trim()),
|
||||
text: watermark.trim(),
|
||||
},
|
||||
};
|
||||
setPublishing(true);
|
||||
setPublished(0);
|
||||
setError(null);
|
||||
let done = 0;
|
||||
// One context and one shader compile for the whole batch: a proof run over
|
||||
// an event would otherwise create and tear down a renderer per photo.
|
||||
let shared: Renderer | null = null;
|
||||
try {
|
||||
shared = new Renderer(document.createElement('canvas'));
|
||||
} catch {
|
||||
shared = null;
|
||||
}
|
||||
try {
|
||||
for (const photo of photos) {
|
||||
const blob = await renderPhotoBlob(photo, PROOF_EXPORT);
|
||||
const blob = await renderPhotoBlob(photo, proofExport, shared ?? undefined);
|
||||
const result = await pushProof(photo.id, await proofBase64(blob));
|
||||
onProofPublished?.(photo.id, result.thumbUrl, result.proofAt);
|
||||
done += 1;
|
||||
@@ -113,6 +150,7 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
setError(err instanceof Error ? err.message : 'Could not publish the edited proofs');
|
||||
return done;
|
||||
} finally {
|
||||
shared?.dispose();
|
||||
setPublishing(false);
|
||||
}
|
||||
};
|
||||
@@ -122,9 +160,10 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
setError(null);
|
||||
try {
|
||||
await createShare(event.id);
|
||||
await refresh();
|
||||
const state = await getShare(event.id);
|
||||
setShare(state);
|
||||
// A gallery without rendered proofs would show the unedited originals.
|
||||
await publishProofs();
|
||||
await publishProofs(state.settings?.watermark ?? '');
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Could not create the link');
|
||||
} finally {
|
||||
@@ -144,6 +183,28 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
}
|
||||
};
|
||||
|
||||
const saveSettings = async (password?: string) => {
|
||||
if (savingSettings) return;
|
||||
setSavingSettings(true);
|
||||
setError(null);
|
||||
try {
|
||||
const settings = await saveShareSettings(event.id, {
|
||||
...(password === undefined ? {} : { password }),
|
||||
expiresAt: expiryDraft ? new Date(`${expiryDraft}T23:59:59`).getTime() : null,
|
||||
watermark: watermarkDraft.trim(),
|
||||
allowDownloads: downloadsOn,
|
||||
downloadCap: Math.max(0, Math.round(Number(capDraft) || 0)),
|
||||
});
|
||||
setShare((prev) => (prev ? { ...prev, settings } : prev));
|
||||
setPasswordDraft('');
|
||||
onToast(password === '' ? 'Gallery password removed' : 'Gallery settings saved');
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Could not save the gallery settings');
|
||||
} finally {
|
||||
setSavingSettings(false);
|
||||
}
|
||||
};
|
||||
|
||||
const revoke = async () => {
|
||||
if (!window.confirm('Turn off this proofing link? Anyone using it will lose access and its picks will be cleared.')) {
|
||||
return;
|
||||
@@ -212,6 +273,91 @@ export default function ShareModal({ event, photos, onClose, onToast, onProofPub
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="share-settings">
|
||||
<div className="share-picks-head">
|
||||
<span>Access and delivery</span>
|
||||
<span className="muted small">
|
||||
{share.settings?.passwordSet ? 'Password protected' : 'Anyone with the link'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="share-settings-grid">
|
||||
<label>
|
||||
<span>Password</span>
|
||||
<input
|
||||
type="password"
|
||||
value={passwordDraft}
|
||||
autoComplete="new-password"
|
||||
placeholder={
|
||||
share.settings?.passwordSet ? 'Set — type a new one' : 'Optional'
|
||||
}
|
||||
onChange={(e) => setPasswordDraft(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Expires</span>
|
||||
<input
|
||||
type="date"
|
||||
value={expiryDraft}
|
||||
onChange={(e) => setExpiryDraft(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>Download cap</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
step={1}
|
||||
value={capDraft}
|
||||
onChange={(e) => setCapDraft(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="share-settings-wide">
|
||||
<span>Watermark on proofs</span>
|
||||
<input
|
||||
value={watermarkDraft}
|
||||
maxLength={80}
|
||||
placeholder="© Studio name"
|
||||
onChange={(e) => setWatermarkDraft(e.target.value)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div className="share-settings-actions">
|
||||
<button
|
||||
className={`chip tiny ${downloadsOn ? 'on' : ''}`}
|
||||
onClick={() => setDownloadsOn((v) => !v)}
|
||||
title="Let clients download their picks"
|
||||
>
|
||||
Downloads {downloadsOn ? 'on' : 'off'}
|
||||
</button>
|
||||
<span className="muted small">
|
||||
Cap 0 means unlimited · {share.settings?.downloadCount ?? 0} used
|
||||
</span>
|
||||
<div className="spacer" />
|
||||
{share.settings?.passwordSet && (
|
||||
<button
|
||||
className="btn ghost small"
|
||||
disabled={savingSettings}
|
||||
onClick={() => void saveSettings('')}
|
||||
>
|
||||
Remove password
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn primary small"
|
||||
disabled={savingSettings}
|
||||
onClick={() =>
|
||||
void saveSettings(passwordDraft.trim() ? passwordDraft.trim() : undefined)
|
||||
}
|
||||
>
|
||||
{savingSettings ? 'Saving…' : 'Save settings'}
|
||||
</button>
|
||||
</div>
|
||||
<p className="muted small">
|
||||
Expiry closes the link at the end of that day. The watermark is rendered into
|
||||
freshly published proofs; republish after changing it.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="share-publish">
|
||||
<div>
|
||||
<strong>Edited proofs</strong>
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { listTether, removeTetherFile, tetherFileUrl } from '../lib/api';
|
||||
import type { TetherFile } from '../lib/api';
|
||||
|
||||
interface Props {
|
||||
event: { id: string; name: string };
|
||||
/** Imports the frames and resolves with how many became photos. */
|
||||
onImport: (files: File[]) => Promise<number>;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
interface LogEntry {
|
||||
name: string;
|
||||
at: number;
|
||||
ok: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
const POLL_MS = 4000;
|
||||
|
||||
function stamp(ms: number) {
|
||||
return new Date(ms).toLocaleTimeString(undefined, {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tethering: watch a folder on the server and import what appears in it.
|
||||
*
|
||||
* Cameras and capture apps write into `<data>/tether/<event>`; this panel
|
||||
* polls that folder, pulls each new frame, runs the normal import path (so raw
|
||||
* decoding, metadata and cloud mirroring all behave the same as a drag and
|
||||
* drop), then deletes the file from the folder. A file is only deleted after a
|
||||
* successful import, so a closed tab or a dropped connection leaves it queued.
|
||||
*/
|
||||
export default function TetherPanel({ event, onImport, onClose }: Props) {
|
||||
const [folder, setFolder] = useState('');
|
||||
const [waiting, setWaiting] = useState<TetherFile[]>([]);
|
||||
const [log, setLog] = useState<LogEntry[]>([]);
|
||||
const [watching, setWatching] = useState(true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [imported, setImported] = useState(0);
|
||||
const seen = useRef(new Set<string>());
|
||||
const working = useRef(false);
|
||||
const watchingRef = useRef(true);
|
||||
watchingRef.current = watching;
|
||||
|
||||
const drain = useCallback(async () => {
|
||||
if (working.current || !watchingRef.current) return;
|
||||
working.current = true;
|
||||
setBusy(true);
|
||||
try {
|
||||
const state = await listTether(event.id);
|
||||
setFolder(state.folder);
|
||||
setWaiting(state.files);
|
||||
setError(null);
|
||||
for (const file of state.files) {
|
||||
if (!watchingRef.current) break;
|
||||
const key = `${file.name}:${file.mtime}:${file.size}`;
|
||||
if (seen.current.has(key)) continue;
|
||||
seen.current.add(key);
|
||||
try {
|
||||
const res = await fetch(tetherFileUrl(event.id, file.name), {
|
||||
credentials: 'same-origin',
|
||||
});
|
||||
if (!res.ok) throw new Error(`Download failed (${res.status})`);
|
||||
const blob = await res.blob();
|
||||
const upload = new File([blob], file.name, {
|
||||
type: blob.type || 'application/octet-stream',
|
||||
lastModified: file.mtime,
|
||||
});
|
||||
const count = await onImport([upload]);
|
||||
if (count < 1) {
|
||||
seen.current.delete(key);
|
||||
throw new Error('Nothing was imported');
|
||||
}
|
||||
await removeTetherFile(event.id, file.name).catch(() => undefined);
|
||||
setImported((n) => n + count);
|
||||
setLog((entries) =>
|
||||
[{ name: file.name, at: Date.now(), ok: true, message: 'imported' }, ...entries].slice(0, 40),
|
||||
);
|
||||
setWaiting((files) => files.filter((item) => item.name !== file.name));
|
||||
} catch (err) {
|
||||
seen.current.delete(key);
|
||||
setLog((entries) =>
|
||||
[
|
||||
{
|
||||
name: file.name,
|
||||
at: Date.now(),
|
||||
ok: false,
|
||||
message: err instanceof Error ? err.message : 'Import failed',
|
||||
},
|
||||
...entries,
|
||||
].slice(0, 40),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Could not read the tether folder');
|
||||
} finally {
|
||||
working.current = false;
|
||||
setBusy(false);
|
||||
}
|
||||
}, [event.id, onImport]);
|
||||
|
||||
useEffect(() => {
|
||||
void drain();
|
||||
const timer = window.setInterval(() => void drain(), POLL_MS);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [drain]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="modal-backdrop"
|
||||
onPointerDown={(e) => e.target === e.currentTarget && onClose()}
|
||||
>
|
||||
<div className="modal tether-modal" role="dialog" aria-modal="true" aria-label="Tethering">
|
||||
<header className="modal-head">
|
||||
<div>
|
||||
<h2>Tethering</h2>
|
||||
<p className="muted small">
|
||||
Frames dropped into the folder are imported into “{event.name}” automatically.
|
||||
</p>
|
||||
</div>
|
||||
<button className="icon-btn" onClick={onClose} title="Close">
|
||||
×
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div className="modal-body">
|
||||
{error && <div className="banner error">{error}</div>}
|
||||
|
||||
<div className="tether-folder">
|
||||
<span className="muted small">Watch folder on the server</span>
|
||||
<code>{folder || 'Reading…'}</code>
|
||||
<p className="muted small">
|
||||
Point a tethering app, a camera's transfer folder or a sync client at this path.
|
||||
JPEG, TIFF, WebP and camera raw files are picked up.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="tether-actions">
|
||||
<button
|
||||
className={`chip ${watching ? 'on' : ''}`}
|
||||
onClick={() => setWatching((value) => !value)}
|
||||
>
|
||||
{watching ? 'Watching' : 'Paused'}
|
||||
</button>
|
||||
<span className="muted small">
|
||||
{busy
|
||||
? 'Pulling frames…'
|
||||
: waiting.length
|
||||
? `${waiting.length} frame${waiting.length === 1 ? '' : 's'} queued`
|
||||
: 'Folder is empty'}
|
||||
</span>
|
||||
<div className="spacer" />
|
||||
<span className="muted small">
|
||||
{imported} imported this session
|
||||
</span>
|
||||
<button className="btn ghost small" onClick={() => void drain()} disabled={busy}>
|
||||
Check now
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{log.length > 0 && (
|
||||
<ul className="tether-log">
|
||||
{log.map((entry, index) => (
|
||||
<li key={`${entry.name}:${entry.at}:${index}`} className={entry.ok ? 'ok' : 'fail'}>
|
||||
<span className="tether-time">{stamp(entry.at)}</span>
|
||||
<span className="tether-name" title={entry.name}>
|
||||
{entry.name}
|
||||
</span>
|
||||
<span className="muted small">{entry.message}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<footer className="modal-foot">
|
||||
<span className="muted small">
|
||||
Files leave the folder only after a successful import.
|
||||
</span>
|
||||
<button className="btn" onClick={onClose}>
|
||||
Done
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user