Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e41fcd7ae1 | ||
|
|
4fd156671d |
No files matched your search
@@ -49,15 +49,18 @@ export function noiseReduction(iso: number | null | undefined): Record<string, n
|
||||
}
|
||||
|
||||
/**
|
||||
* How much of a measured tone slider to keep. Exposure and contrast stay at `strength` (the event's 75%).
|
||||
* In reportage a blown highlight is pulled and a blocked shadow is opened at the full amount the meter asked,
|
||||
* and only in that direction: a dark highlight is not lifted, a bright shadow is not crushed.
|
||||
* Highlights and shadows from Auto are one fixed recipe (the average Lightroom chose on raw files), not a
|
||||
* reading of this photo. On a camera JPEG the full figure greys a white banner and flattens a face.
|
||||
* Exposure and contrast stay at `strength`. The highlight pull and the shadow lift stop at these.
|
||||
*/
|
||||
export function toneApplied(key: string, measured: number, strength: number, reportage: boolean): number {
|
||||
if (reportage && key === "light.highlights" && measured < 0) return measured;
|
||||
if (reportage && key === "light.whites" && measured < 0) return measured;
|
||||
if (reportage && key === "light.shadows" && measured > 0) return measured;
|
||||
return measured * strength;
|
||||
const HIGHLIGHT_PULL = 20;
|
||||
const SHADOW_LIFT = 30;
|
||||
|
||||
export function toneApplied(key: string, measured: number, strength: number): number {
|
||||
let value = measured * strength;
|
||||
if ((key === "light.highlights" || key === "light.whites") && value < -HIGHLIGHT_PULL) value = -HIGHLIGHT_PULL;
|
||||
if (key === "light.shadows" && value > SHADOW_LIFT) value = SHADOW_LIFT;
|
||||
return Math.round(value * 100) / 100;
|
||||
}
|
||||
|
||||
/** Local contrast and sharpening. Their kernel is a fraction of the whole frame, so a tight crop shows them enlarged. */
|
||||
|
||||
@@ -117,7 +117,7 @@ export class AutopilotService {
|
||||
if (engine && (settings.tone || settings.whiteBalance || settings.level)) {
|
||||
const auto = await engine.auto(preview, null);
|
||||
rawAngle = auto.angle;
|
||||
values = measuredValues(auto.values, settings, reportage, photo.iso, style?.offsets ?? {});
|
||||
values = measuredValues(auto.values, settings, photo.iso, style?.offsets ?? {});
|
||||
}
|
||||
const angle = levelAngle(rawAngle, settings.level);
|
||||
const load = this.deps.detector();
|
||||
|
||||
@@ -30,11 +30,11 @@ export function levelAngle(angle: number | null, enabled: boolean): number {
|
||||
/**
|
||||
* White balance, tone and the finishing look, before the crop scales detail. Null when none of those are on:
|
||||
* the same gate the server uses (it measures only when tone, white balance or level is enabled).
|
||||
* Highlight and shadow figures are capped in `toneApplied`: Auto's recipe is not a reading of this photo.
|
||||
*/
|
||||
export function measuredValues(
|
||||
auto: Record<string, number>,
|
||||
settings: PlanSettings,
|
||||
reportage: boolean,
|
||||
iso: number | null,
|
||||
offsets: Record<string, number>,
|
||||
): Record<string, number> | null {
|
||||
@@ -43,7 +43,7 @@ export function measuredValues(
|
||||
if (settings.whiteBalance) for (const k of WB_KEYS) if (auto[k] !== undefined) values[k] = auto[k]! + (offsets[k] ?? 0);
|
||||
if (settings.tone) {
|
||||
for (const k of TONE_KEYS) {
|
||||
const v = toneApplied(k, auto[k] ?? 0, settings.toneStrength, reportage) + (offsets[k] ?? 0);
|
||||
const v = toneApplied(k, auto[k] ?? 0, settings.toneStrength) + (offsets[k] ?? 0);
|
||||
if (v) values[k] = Math.round(v * 100) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,13 @@ describe("autopilot look", () => {
|
||||
expect(Object.keys(agency).some((k) => k.startsWith("vignette."))).toBe(false);
|
||||
});
|
||||
|
||||
it("opens blocked shadows and pulls blown highlights in full for reportage, and only that way", () => {
|
||||
expect(toneApplied("light.highlights", -40, 0.75, true)).toBe(-40);
|
||||
expect(toneApplied("light.shadows", 35, 0.75, true)).toBe(35);
|
||||
expect(toneApplied("light.whites", -20, 0.75, true)).toBe(-20);
|
||||
expect(toneApplied("light.highlights", 10, 0.75, true)).toBe(7.5);
|
||||
expect(toneApplied("light.shadows", -10, 0.75, true)).toBe(-7.5);
|
||||
expect(toneApplied("light.exposure", 0.4, 0.75, true)).toBeCloseTo(0.3);
|
||||
expect(toneApplied("light.highlights", -40, 0.75, false)).toBe(-30);
|
||||
it("keeps the fixed highlight and shadow recipe from greying a JPEG", () => {
|
||||
expect(toneApplied("light.highlights", -66, 0.75)).toBe(-20);
|
||||
expect(toneApplied("light.shadows", 52, 0.75)).toBe(30);
|
||||
expect(toneApplied("light.whites", -40, 0.75)).toBe(-20);
|
||||
expect(toneApplied("light.highlights", -10, 0.75)).toBe(-7.5);
|
||||
expect(toneApplied("light.contrast", 68, 0.75)).toBe(51);
|
||||
expect(toneApplied("light.exposure", -0.25, 0.75)).toBeCloseTo(-0.19);
|
||||
});
|
||||
|
||||
it("keeps structure and sharpen in proportion to the frame a crop keeps", () => {
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
import { controlsForModule, type Module } from "@photoreport/contracts";
|
||||
import { useState } from "react";
|
||||
import type { Module } from "@photoreport/contracts";
|
||||
import { t } from "../i18n.js";
|
||||
import { SYNC_MODULES } from "./copySettings.js";
|
||||
|
||||
/** Copy chosen groups from the active photo onto the other selected ones. Crop starts off. */
|
||||
export function SyncSettingsButton({ count, disabled, onApply }: { count: number; disabled?: boolean; onApply: (modules: Module[]) => Promise<void> }) {
|
||||
const BASIC_IDS = controlsForModule("basic").map((c) => c.id);
|
||||
|
||||
export interface SyncPick {
|
||||
controls: string[];
|
||||
crop: boolean;
|
||||
}
|
||||
|
||||
function labelOf(id: string): string {
|
||||
const labels = t.dev.labels as Record<string, string>;
|
||||
return labels[id] ?? id;
|
||||
}
|
||||
|
||||
/** Copy chosen controls from the active photo onto the other selected ones. Crop starts off. Basic starts on, and each of its sliders can be ticked alone. */
|
||||
export function SyncSettingsButton({ count, disabled, onApply }: { count: number; disabled?: boolean; onApply: (pick: SyncPick) => Promise<void> }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [picked, setPicked] = useState<Module[]>(["basic"]);
|
||||
const [picked, setPicked] = useState<string[]>(BASIC_IDS);
|
||||
const [crop, setCrop] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const toggle = (module: Module) => setPicked((cur) => (cur.includes(module) ? cur.filter((m) => m !== module) : [...cur, module]));
|
||||
const has = (id: string) => picked.includes(id);
|
||||
const toggle = (id: string) => setPicked((cur) => (cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id]));
|
||||
const toggleModule = (module: Module) => {
|
||||
const ids = controlsForModule(module).map((c) => c.id);
|
||||
const all = ids.every((id) => picked.includes(id));
|
||||
setPicked((cur) => (all ? cur.filter((id) => !ids.includes(id)) : [...new Set([...cur, ...ids])]));
|
||||
};
|
||||
return (
|
||||
<span className="relative">
|
||||
<button
|
||||
@@ -20,25 +39,51 @@ export function SyncSettingsButton({ count, disabled, onApply }: { count: number
|
||||
{t.dev.sync} ({count})
|
||||
</button>
|
||||
{open && (
|
||||
<div className="absolute right-0 z-20 mt-1 w-56 border border-black bg-raised p-2 text-[12px] text-ink shadow-lg">
|
||||
<div className="absolute right-0 z-20 mt-1 w-64 border border-black bg-raised p-2 text-[12px] text-ink shadow-lg">
|
||||
<p className="mb-2 text-[11px] text-muted">{t.dev.syncHelp}</p>
|
||||
<ul className="flex max-h-64 flex-col gap-1 overflow-auto">
|
||||
{SYNC_MODULES.map((module) => (
|
||||
<li key={module}>
|
||||
<label className="flex items-center gap-2">
|
||||
<input type="checkbox" checked={picked.includes(module)} onChange={() => toggle(module)} />
|
||||
{t.modules[module]}
|
||||
</label>
|
||||
</li>
|
||||
))}
|
||||
<ul className="flex max-h-72 flex-col gap-1 overflow-auto">
|
||||
{SYNC_MODULES.map((module) => {
|
||||
const ids = controlsForModule(module).map((c) => c.id);
|
||||
if (module === "crop") {
|
||||
return (
|
||||
<li key={module}>
|
||||
<label className="flex items-center gap-2">
|
||||
<input type="checkbox" checked={crop} onChange={() => setCrop((v) => !v)} />
|
||||
{t.modules[module]}
|
||||
</label>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
const all = ids.length > 0 && ids.every((id) => has(id));
|
||||
return (
|
||||
<li key={module}>
|
||||
<label className="flex items-center gap-2">
|
||||
<input type="checkbox" checked={all} onChange={() => toggleModule(module)} />
|
||||
{t.modules[module]}
|
||||
</label>
|
||||
{module === "basic" && (
|
||||
<ul className="mt-1 flex flex-col gap-1 pl-5">
|
||||
{ids.map((id) => (
|
||||
<li key={id}>
|
||||
<label className="flex items-center gap-2">
|
||||
<input type="checkbox" checked={has(id)} onChange={() => toggle(id)} />
|
||||
{labelOf(id)}
|
||||
</label>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<button
|
||||
type="button"
|
||||
className="mt-2 h-7 w-full bg-accent font-semibold text-white disabled:opacity-40"
|
||||
disabled={busy || !picked.length}
|
||||
disabled={busy || (!picked.length && !crop)}
|
||||
onClick={() => {
|
||||
setBusy(true);
|
||||
void onApply(picked)
|
||||
void onApply({ controls: picked, crop })
|
||||
.then(() => setOpen(false))
|
||||
.finally(() => setBusy(false));
|
||||
}}
|
||||
|
||||
@@ -8,11 +8,12 @@ import { cropOf, localOutbox } from "./session.js";
|
||||
/** Groups the photographer can copy. Crop is listed and starts off. */
|
||||
export const SYNC_MODULES: Module[] = MODULES.filter((m) => m === "crop" || controlsForModule(m).length > 0);
|
||||
|
||||
/** Only the controls in the chosen groups. Other controls on the target photo stay as they are. */
|
||||
export function syncDevelopCommand(modules: readonly Module[], value: (id: string) => number): EditCommand | null {
|
||||
/** Only the chosen controls. Other controls on the target photo stay as they are. */
|
||||
export function syncDevelopCommand(controlIds: readonly string[], value: (id: string) => number): EditCommand | null {
|
||||
const wanted = new Set(controlIds);
|
||||
const values: Record<string, number> = {};
|
||||
for (const c of CONTROLS) {
|
||||
if (c.module === "crop" || !modules.includes(c.module)) continue;
|
||||
if (c.module === "crop" || !wanted.has(c.id)) continue;
|
||||
const v = value(c.id);
|
||||
if (Number.isFinite(v)) values[c.id] = v;
|
||||
}
|
||||
@@ -25,11 +26,11 @@ export function syncCropCommand(settings: string): EditCommand {
|
||||
return { command: "crop.set", params: { rect: crop.rect, angle: crop.angle, aspect: crop.aspect } };
|
||||
}
|
||||
|
||||
export function commandsFrom(modules: readonly Module[], settings: string, value: (id: string) => number): EditCommand[] {
|
||||
export function commandsFrom(controlIds: readonly string[], crop: boolean, settings: string, value: (id: string) => number): EditCommand[] {
|
||||
const out: EditCommand[] = [];
|
||||
const develop = syncDevelopCommand(modules, value);
|
||||
const develop = syncDevelopCommand(controlIds, value);
|
||||
if (develop) out.push(develop);
|
||||
if (modules.includes("crop")) out.push(syncCropCommand(settings));
|
||||
if (crop) out.push(syncCropCommand(settings));
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -61,10 +62,10 @@ export async function settingsOf(api: ApiClient, photoId: string): Promise<strin
|
||||
return settings;
|
||||
}
|
||||
|
||||
export async function commandsForPhoto(api: ApiClient, photoId: string, modules: readonly Module[]): Promise<EditCommand[]> {
|
||||
export async function commandsForPhoto(api: ApiClient, photoId: string, controlIds: readonly string[], crop: boolean): Promise<EditCommand[]> {
|
||||
const engine = await loadEngine();
|
||||
const settings = await settingsOf(api, photoId);
|
||||
return commandsFrom(modules, settings, (id) => engine.value(settings, id));
|
||||
return commandsFrom(controlIds, crop, settings, (id) => engine.value(settings, id));
|
||||
}
|
||||
|
||||
/** Queue the commands for the other selected photos. They go out with the socket, and follow a local photo. */
|
||||
|
||||
@@ -1043,7 +1043,7 @@ export const t = {
|
||||
paste: "Colar ajustes",
|
||||
pasted: (n: number) => `Ajustes colados em ${n} ${n === 1 ? "foto" : "fotos"}`,
|
||||
sync: "Sincronizar ajustes",
|
||||
syncHelp: "Copia os grupos escolhidos da foto activa para as outras seleccionadas. O recorte fica de fora até o ligares.",
|
||||
syncHelp: "Copia o que estiver marcado da foto activa para as outras seleccionadas. Dentro de Básico podes marcar só um ajuste, por exemplo os realces. O recorte fica de fora até o ligares.",
|
||||
syncApply: "Aplicar",
|
||||
synced: (n: number) => `Ajustes sincronizados em ${n} ${n === 1 ? "foto" : "fotos"}`,
|
||||
noAccess: "Só podes revelar fotos que enviaste.",
|
||||
|
||||
@@ -34,7 +34,7 @@ export async function planLocalAutopilot(args: {
|
||||
// Both have to be here. A crop without the tone, or the reverse, would stop the server doing the rest.
|
||||
if (!measured || !detections) return;
|
||||
const angle = levelAngle(measured.angle, settings.level);
|
||||
const values = measuredValues(measured.values, settings, reportage, args.iso ?? null, style?.offsets ?? {});
|
||||
const values = measuredValues(measured.values, settings, args.iso ?? null, style?.offsets ?? {});
|
||||
const planned = planFrame({
|
||||
detections,
|
||||
width: args.width,
|
||||
|
||||
@@ -40,12 +40,11 @@ describe("shared detector decode", () => {
|
||||
|
||||
describe("sync chosen groups", () => {
|
||||
it("writes the chosen controls and leaves the crop for its own command", () => {
|
||||
const cmd = syncDevelopCommand(["basic"], (id) => (id === "light.exposure" ? 0.4 : 0));
|
||||
const cmd = syncDevelopCommand(["light.highlights"], (id) => (id === "light.highlights" ? -20 : 0));
|
||||
expect(cmd?.command).toBe("develop.set");
|
||||
if (cmd?.command !== "develop.set") return;
|
||||
expect(cmd.params.values["light.exposure"]).toBe(0.4);
|
||||
expect(cmd.params.values["crop.angle"]).toBeUndefined();
|
||||
expect(syncDevelopCommand(["crop"], () => 1)).toBeNull();
|
||||
expect(cmd.params.values).toEqual({ "light.highlights": -20 });
|
||||
expect(syncDevelopCommand([], () => 1)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -741,9 +741,9 @@ export function DevelopPage() {
|
||||
<SyncSettingsButton
|
||||
count={[...selected].filter((id) => id !== current.id).length}
|
||||
disabled={!canEdit || !session?.loaded}
|
||||
onApply={async (modules) => {
|
||||
onApply={async ({ controls, crop }) => {
|
||||
if (!session?.loaded || !current) return;
|
||||
const commands = commandsFrom(modules, session.settings, (id) => session.value(id));
|
||||
const commands = commandsFrom(controls, crop, session.settings, (id) => session.value(id));
|
||||
const ids = [...selected].filter((id) => id !== current.id);
|
||||
if (!commands.length || !ids.length) return;
|
||||
queueSync(orgId, ids, commands);
|
||||
|
||||
@@ -566,8 +566,8 @@ export function LibraryPage() {
|
||||
{canCull && focus && selection.length > 1 && (
|
||||
<SyncSettingsButton
|
||||
count={selection.filter((p) => p.id !== focus.id).length}
|
||||
onApply={async (modules) => {
|
||||
const commands = await commandsForPhoto(api, focus.id, modules);
|
||||
onApply={async ({ controls, crop }) => {
|
||||
const commands = await commandsForPhoto(api, focus.id, controls, crop);
|
||||
const ids = selection.map((p) => p.id).filter((id) => id !== focus.id);
|
||||
if (!commands.length || !ids.length) return;
|
||||
queueSync(orgId, ids, commands);
|
||||
|
||||
@@ -117,8 +117,9 @@ every photo of a match. They never go over a measured control.
|
||||
(never under a third), so a tight portrait does not grow a halo. There is never a vignette or a local change (§1).
|
||||
|
||||
Defaults follow the agencies: white balance on (neutral whites) and 75% of the automatic tone (full range,
|
||||
pure blacks). In reportage the measured highlights and whites are pulled in full when they are too bright, and
|
||||
the measured shadows are opened in full when they are blocked. Neither slider is pushed the other way.
|
||||
pure blacks). Highlights and shadows in that automatic tone are one fixed recipe from raw files, not a reading
|
||||
of the photo. On a camera JPEG the full recipe greys whites and flattens faces, so the highlight pull stops at
|
||||
−20 and the shadow lift at +30.
|
||||
|
||||
Uploads made by hand in the browser are not touched. Anything the autopilot did can be undone, changed or reset
|
||||
in Revelar.
|
||||
|
||||
Reference in new issue
Block a user