Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d76fe4726 | ||
|
|
e380a593b5 | ||
|
|
e2864338fc | ||
|
|
2279b02786 | ||
|
|
0e6a1361da | ||
|
|
d6e3078124 |
No files matched your search
@@ -9,9 +9,10 @@
|
||||
* body a little above the middle and little or no empty pitch under the feet (spare height goes above, to the
|
||||
* crowd and the stands). A foot that is whole in the photo stays in; heads and the ball are never cut.
|
||||
* - Cutting another sharp person in half is avoided; cutting blurred ones doesn't matter.
|
||||
* - A generic event, and any photo with no ball, is reportage: a whole hand and a whole foot stay in. A leg is
|
||||
* cut only when the foot already leaves the photo. A stray hand or foot of someone else is cropped out.
|
||||
* A head in a window or a torso does not beat a whole figure, and a crop never slices someone who is in it.
|
||||
* - A generic event, and any photo with no ball, is reportage: a whole hand and a whole foot stay in. When the
|
||||
* foot already leaves the photo, the crop ends mid-shin or mid-thigh, never on the sock. A person the frame
|
||||
* has already cut in half stays out. A stray hand or foot of someone else is cropped out. A head in a window
|
||||
* or a torso does not beat a whole figure, and a crop never slices someone who is in it.
|
||||
* - "tight" is the agencies' handball look, and only with a ball in play: the subject fills the height, cut
|
||||
* mid-shin or mid-thigh when the foot is already out. "full" keeps whole bodies when they fit.
|
||||
*
|
||||
@@ -199,19 +200,25 @@ export function findSubject(d: Detections, focus?: FocusHint | null, opts?: { re
|
||||
const main = aimed ?? pool.reduce((a, b) => (weight(b) > weight(a) ? b : a));
|
||||
if (!aimed && weight(main) < 0.05) return null;
|
||||
// Reportage keeps a conversation together: someone in the shade is still part of it. A match stays stricter.
|
||||
// Someone who merely touches the edge but is a whole figure is still in the conversation. A short box on the
|
||||
// edge is a stray hand or foot.
|
||||
// A body the frame has already cut in half is not part of that conversation, unless it is the subject.
|
||||
const withMain = opts?.reportage ? 0.35 : TUNING.inFocus;
|
||||
const reach = opts?.reportage ? 0.85 : 0.45;
|
||||
const leaves = (p: Detection) => atEdge(p) && (!opts?.reportage || h(p) < 0.5);
|
||||
const focused = people.filter((p) => sharp(p) >= withMain * sharp(main) && !leaves(p));
|
||||
const cutOff = (p: Detection) => atEdge(p) && p !== main;
|
||||
const focused = people.filter((p) => sharp(p) >= withMain * sharp(main) && !cutOff(p));
|
||||
|
||||
// A ball in play near the subject: in the hands, at the feet, or in the air just above.
|
||||
// A ball in play near the subject: in the hands, at the feet, or in the air just above. The one on the person
|
||||
// wins over a spare ball sitting on the floor.
|
||||
const balls = d.balls.filter((b) => b.score >= MIN_BALL && w(b) < 0.6 * h(main) && w(b) > 0.02 * h(main));
|
||||
const ball = balls.find((b) => Math.abs(cx(b) - cx(main)) <= w(main) / 2 + 0.5 * h(main) && cy(b) > main.y0 - 0.4 * h(main) && cy(b) < main.y1 + 0.1 * h(main));
|
||||
const near = balls.filter((b) => Math.abs(cx(b) - cx(main)) <= w(main) / 2 + 0.5 * h(main) && cy(b) > main.y0 - 0.4 * h(main) && cy(b) < main.y1 + 0.1 * h(main));
|
||||
const ball = near.sort((a, b) => {
|
||||
const held = (x: Box) => (overlap(x, main) > 0 ? 0 : 1);
|
||||
const dist = (x: Box) => (cx(x) - cx(main)) ** 2 + (cy(x) - cy(main)) ** 2;
|
||||
return held(a) - held(b) || dist(a) - dist(b);
|
||||
})[0];
|
||||
if (ball) {
|
||||
// Everyone big and close to the ball is in the duel, in focus or not (the goalkeeper facing the shot).
|
||||
const contest = people.filter((p) => p === main || (h(p) >= 0.6 * h(main) && Math.abs(cx(p) - cx(ball)) <= 0.9 * h(main) && overlap(p, { x0: 0, y0: 0, x1: 1, y1: 1 }) > 0.7 * area(p)));
|
||||
// Not someone the frame has already cut in half: they are background, and the crop leaves them out.
|
||||
const contest = people.filter((p) => p === main || (!cutOff(p) && h(p) >= 0.6 * h(main) && Math.abs(cx(p) - cx(ball)) <= 0.9 * h(main) && overlap(p, { x0: 0, y0: 0, x1: 1, y1: 1 }) > 0.7 * area(p)));
|
||||
if (!contest.includes(main)) contest.push(main);
|
||||
const box = contest.reduce<Box>((u, p) => union(u, p), { x0: ball.x0, y0: ball.y0, x1: ball.x1, y1: ball.y1 });
|
||||
return { box, reason: "ball", people: contest, ball };
|
||||
@@ -275,31 +282,53 @@ export function compose(d: Detections, aspect: number | null = null, opts: Compo
|
||||
// for a ball in play. A complete hand or foot is never cut just to fill the frame.
|
||||
const personStory = opts.context === "reportage" || !ball;
|
||||
if (opts.framing === "tight" && !personStory) {
|
||||
// The ball (and the hands on it) is never cut: the bottom edge stays below it.
|
||||
const keep = (y: number) => Math.min(s.y1, Math.max(y, ball ? ball.y1 + 0.01 : 0));
|
||||
// Feet that are whole in the photo stay in. Mid-shin and mid-thigh are only for a body the frame does
|
||||
// not finish, and only when the whole body cannot fit. The hip (a joint) is never the cut.
|
||||
// Feet that are whole in the photo stay in. Cutting the leg is not how a tight frame is made.
|
||||
if (feetIn) {
|
||||
// Headroom gives way before a complete foot does. Cutting the leg is not how a tight frame is made.
|
||||
// Headroom gives way before a complete foot does.
|
||||
const whole = frame(s, ratio, sole, headroom, tallest, others, inSubject, reason, minWidth, true)
|
||||
?? frame(s, ratio, sole, 0, tallest, others, inSubject, reason, minWidth, true)
|
||||
?? frame(s, ratio, s.y1, 0, tallest, others, inSubject, reason, minWidth, true);
|
||||
if (whole) return { rect: whole.rect, subject: whole.subject, reason: whole.reason, people: whole.people };
|
||||
}
|
||||
const tries = [keep(s.y0 + MID_SHIN * tallest), keep(s.y0 + MID_THIGH * tallest)]
|
||||
.map((bottom) => frame(s, ratio, bottom, headroom, tallest, others, inSubject, reason, minWidth, true))
|
||||
.filter((c): c is Composition & { cost: number } => !!c);
|
||||
const best = tries.reduce<(Composition & { cost: number }) | null>((a, b) => (!a || b.cost < a.cost ? b : a), null);
|
||||
if (best) return { rect: best.rect, subject: best.subject, reason: best.reason, people: best.people };
|
||||
return frame(s, ratio, keep(s.y0 + MID_THIGH * tallest), headroom, tallest, others, inSubject, reason, minWidth, true);
|
||||
// The foot already leaves the photo: end mid-shin or mid-thigh, not on the sock.
|
||||
const cut = cutAboveTheAnkle(s, ratio, headroom, tallest, others, inSubject, reason, minWidth, true, false, ball);
|
||||
if (cut) return { rect: cut.rect, subject: cut.subject, reason: cut.reason, people: cut.people };
|
||||
return null;
|
||||
}
|
||||
// Whole bodies, feet included. A little headroom gives way before a complete foot does. Mid-thigh only when
|
||||
// the foot already leaves the photo, or the whole body cannot fit at all.
|
||||
// The foot already leaves the photo. Stopping on the sock is the same as cutting the ankle.
|
||||
if (!feetIn) {
|
||||
const cut = cutAboveTheAnkle(s, ratio, headroom, tallest, others, inSubject, reason, minWidth, false, reportage, ball);
|
||||
if (cut) return { rect: cut.rect, subject: cut.subject, reason: cut.reason, people: cut.people };
|
||||
}
|
||||
// Whole bodies, feet included. A little headroom gives way before a complete foot does.
|
||||
const whole = frame(s, ratio, sole, headroom, tallest, others, inSubject, reason, minWidth, false, false, reportage)
|
||||
?? frame(s, ratio, sole, 0, tallest, others, inSubject, reason, minWidth, false, false, reportage)
|
||||
?? frame(s, ratio, s.y1, 0, tallest, others, inSubject, reason, minWidth, false, false, reportage);
|
||||
if (whole || feetIn) return whole;
|
||||
return frame(s, ratio, s.y0 + MID_THIGH * tallest, headroom, tallest, others, inSubject, reason, minWidth);
|
||||
return frame(s, ratio, s.y0 + MID_THIGH * tallest, headroom, tallest, others, inSubject, reason, minWidth, false, true, reportage);
|
||||
}
|
||||
|
||||
/**
|
||||
* The foot is already out of the photo. The crop ends between the joints (mid-shin or mid-thigh), pinned there
|
||||
* so it cannot slide down onto the sock. A ball in the hands stays below the cut. The hip, the knee and the
|
||||
* ankle are never the line.
|
||||
*/
|
||||
function cutAboveTheAnkle(s: Box, ratio: number, headroom: number, tallest: number, others: Detection[], inSubject: Detection[], reason: Composition["reason"], minWidth: number, tight: boolean, reportage: boolean, ball?: Box): (Composition & { cost: number }) | null {
|
||||
// The line is on the person. The subject box can start higher, at a ball held overhead, and that must not
|
||||
// pull the cut up onto the hip.
|
||||
const body = inSubject.reduce((a, b) => (h(b) > h(a) ? b : a));
|
||||
const keep = (y: number) => Math.min(body.y1, Math.max(y, ball ? ball.y1 + 0.01 : 0));
|
||||
const lines = [MID_SHIN, MID_THIGH]
|
||||
.map((at) => keep(body.y0 + at * h(body)))
|
||||
.filter((y) => {
|
||||
const at = (y - body.y0) / Math.max(h(body), 1e-6);
|
||||
if (at > FOOT_ZONE) return false;
|
||||
return !JOINTS.some((j) => Math.abs(at - j) < JOINT_BAND);
|
||||
});
|
||||
const tries = lines
|
||||
.map((bottom) => frame(s, ratio, bottom, headroom, tallest, others, inSubject, reason, minWidth, tight, true, reportage))
|
||||
.filter((c): c is Composition & { cost: number } => !!c);
|
||||
return tries.reduce<(Composition & { cost: number }) | null>((a, b) => (!a || b.cost < a.cost ? b : a), null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,7 +102,8 @@ describe("tight framing (the agencies' handball look)", () => {
|
||||
const full = compose({ ...frame, people: [p], balls: [ball] })!;
|
||||
const tight = compose({ ...frame, people: [p], balls: [ball] }, null, { framing: "tight" })!;
|
||||
const hT = tight.rect.y1 - tight.rect.y0;
|
||||
expect(hT).toBeLessThan(full.rect.y1 - full.rect.y0);
|
||||
// Both stop on the limb once the foot is gone, so the tight frame is not a looser one.
|
||||
expect(hT).toBeLessThanOrEqual(full.rect.y1 - full.rect.y0);
|
||||
expect(tight.rect.y1).toBeLessThan(p.y1);
|
||||
expect(tight.rect.y0).toBeLessThanOrEqual(p.y0);
|
||||
expect(tight.rect.y1).toBeGreaterThan(ball.y1);
|
||||
@@ -172,6 +173,24 @@ describe("reportage", () => {
|
||||
expect(headCut(beside)).toBe(false);
|
||||
});
|
||||
|
||||
it("leaves out a half person at the frame edge, and does not stop on the sock when the feet are already gone", () => {
|
||||
// PSR17710. The player fills the frame down to the socks. Another player is already cut in half on the left,
|
||||
// and a spare ball sits on the floor beside her. The crop is about the player with the ball.
|
||||
const player = { ...person(0.36, 0.15, 0.66, 0.996), sharpness: 1 };
|
||||
const half = { ...person(0, 0.22, 0.14, 0.98), sharpness: 0.7 };
|
||||
const inHand = { x0: 0.48, y0: 0.06, x1: 0.55, y1: 0.16, score: 0.9 };
|
||||
const onTheFloor = { x0: 0.06, y0: 0.7, x1: 0.12, y1: 0.78, score: 0.8 };
|
||||
const c = compose({ width: 6000, height: 4000, people: [player, half], balls: [onTheFloor, inHand] }, null, { context: "reportage", minWidth: 0.4 })!;
|
||||
expect(c.people).toBe(1);
|
||||
expect(c.rect.x0).toBeGreaterThan(half.x1 - 0.02);
|
||||
expect(c.rect.y0).toBeLessThanOrEqual(player.y0);
|
||||
expect(c.rect.y1).toBeGreaterThan(inHand.y1);
|
||||
const at = (c.rect.y1 - player.y0) / (player.y1 - player.y0);
|
||||
expect(at).toBeGreaterThan(0.55);
|
||||
expect(at).toBeLessThanOrEqual(0.9);
|
||||
for (const j of [0.53, 0.74, 0.95]) expect(Math.abs(at - j)).toBeGreaterThanOrEqual(0.035);
|
||||
});
|
||||
|
||||
it("keeps a complete foot when the head is already against the top edge", () => {
|
||||
const p = person(0.4, 0.02, 0.55, 0.984);
|
||||
const c = compose({ ...frame, people: [p], balls: [] }, null, { framing: "tight", context: "reportage" })!;
|
||||
@@ -199,8 +218,11 @@ describe("reportage", () => {
|
||||
];
|
||||
const c = compose({ width: 6000, height: 4000, people: [standing, window], balls: [] }, null, { context: "reportage", faces, minWidth: 0.5 })!;
|
||||
expect(c.rect.y0).toBeLessThanOrEqual(standing.y0 + 1e-6);
|
||||
expect(c.rect.y1).toBeGreaterThan(standing.y1 - 1e-6);
|
||||
expect(c.rect.x0).toBeLessThanOrEqual(standing.x0 + 1e-6);
|
||||
// Her box runs off the bottom, so the cut is mid-limb, not the sock and not a band through the door.
|
||||
const at = (c.rect.y1 - standing.y0) / (standing.y1 - standing.y0);
|
||||
expect(at).toBeGreaterThan(0.55);
|
||||
expect(at).toBeLessThanOrEqual(0.9);
|
||||
const widthIn = Math.max(0, Math.min(c.rect.x1, window.x1) - Math.max(c.rect.x0, window.x0)) / (window.x1 - window.x0);
|
||||
expect(widthIn < 0.12 || widthIn > 0.9).toBe(true);
|
||||
if (widthIn > 0.9) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ArchivePage } from "./pages/ArchivePage.js";
|
||||
import { DevelopPage } from "./pages/DevelopPage.js";
|
||||
import { DeliveryPage } from "./pages/DeliveryPage.js";
|
||||
import { FacesQueuePage } from "./pages/FacesQueuePage.js";
|
||||
import { HelpPage } from "./pages/HelpPage.js";
|
||||
import { NumbersPage } from "./pages/NumbersPage.js";
|
||||
import { PrintPage } from "./pages/PrintPage.js";
|
||||
import { ShopPage } from "./pages/ShopPage.js";
|
||||
@@ -38,6 +39,7 @@ function Gate() {
|
||||
<Route path="numbers" element={<NumbersPage />} />
|
||||
<Route path="members" element={<MembersPage />} />
|
||||
<Route path="preferences" element={<PreferencesPage />} />
|
||||
<Route path="help" element={<HelpPage />} />
|
||||
<Route path="*" element={<p className="p-6 text-sm text-muted">{t.notFound}</p>} />
|
||||
</Route>
|
||||
<Route path="/login" element={<Navigate to="/" replace />} />
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Link } from "react-router";
|
||||
import { t } from "../i18n.js";
|
||||
|
||||
/** A small "i" that opens one chapter of the in-app guide. The tool panel stays free of the explanation. */
|
||||
export function HelpLink({ section, label }: { section: string; label: string }) {
|
||||
const name = `${t.help.menu}: ${label}`;
|
||||
return (
|
||||
<Link
|
||||
to={`/help#${section}`}
|
||||
aria-label={name}
|
||||
title={name}
|
||||
className="inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border border-[#5a5a5a] text-[10px] leading-none text-faint hover:border-ink hover:text-ink"
|
||||
>
|
||||
i
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { controlsForModule, type Module } from "@photoreport/contracts";
|
||||
import { useState } from "react";
|
||||
import { t } from "../i18n.js";
|
||||
import { HelpLink } from "../components/HelpLink.js";
|
||||
import { SYNC_MODULES } from "./copySettings.js";
|
||||
|
||||
const BASIC_IDS = controlsForModule("basic").map((c) => c.id);
|
||||
@@ -40,7 +41,10 @@ export function SyncSettingsButton({ count, disabled, onApply }: { count: number
|
||||
</button>
|
||||
{open && (
|
||||
<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>
|
||||
<div className="mb-2 flex items-start gap-2">
|
||||
<p className="text-[11px] text-muted">{t.dev.syncHelp}</p>
|
||||
<HelpLink section="sincronizar" label={t.help.sincronizar.title} />
|
||||
</div>
|
||||
<ul className="flex max-h-72 flex-col gap-1 overflow-auto">
|
||||
{SYNC_MODULES.map((module) => {
|
||||
const ids = controlsForModule(module).map((c) => c.id);
|
||||
|
||||
+78
-1
@@ -1035,7 +1035,7 @@ export const t = {
|
||||
autoCropHelp: "Recorte automático à volta de quem a foto é: a bola e quem a disputa, ou o grupo principal, sem cortar corpos a meio.",
|
||||
autoCropNone: "Não encontrei um assunto claro nesta foto para recortar.",
|
||||
autoCropMissing: "O recorte automático ainda não está instalado neste servidor.",
|
||||
levelHelp: "Endireita a foto pelo horizonte ou pelas linhas verticais (como o Auto do Lightroom).",
|
||||
levelHelp: "Endireita a foto pelo horizonte ou pelas linhas verticais.",
|
||||
levelNone: "Não encontrei horizonte nem linhas verticais claras nesta foto: endireita com o ângulo.",
|
||||
flagState: "Marcação",
|
||||
straighten: "Endireitar",
|
||||
@@ -1067,6 +1067,83 @@ export const t = {
|
||||
"crop.angle": "Ângulo",
|
||||
} as Record<string, string>,
|
||||
},
|
||||
help: {
|
||||
menu: "Ajuda",
|
||||
title: "Ajuda",
|
||||
intro: "O painel de trabalho fica só com as ferramentas. O que a app faz está aqui, para ler quando precisares.",
|
||||
biblioteca: {
|
||||
title: "Biblioteca",
|
||||
paras: [
|
||||
"Os eventos ficam à esquerda e as fotos no centro.",
|
||||
"P marca a foto como escolhida, X rejeita e U tira a marca. 0 a 5 são as estrelas.",
|
||||
"6 é vermelho, 7 amarelo, 8 verde e 9 azul. Carregar outra vez na mesma cor tira-a.",
|
||||
"No Mac, Cmd+1 a Cmd+5 metem a cor (Cmd+5 é roxo) e Ctrl+1 a Ctrl+5 as estrelas. No Windows, Ctrl+1 a Ctrl+5 a cor e Alt+1 a Alt+5 as estrelas. T marca a escolhida, e outra vez tira.",
|
||||
"Ctrl ou Cmd+A seleciona as fotos que estão à vista, não o texto da página.",
|
||||
],
|
||||
},
|
||||
filtro: {
|
||||
title: "Filtro",
|
||||
caption: "A tira com Escolhidas e pelo menos 2 estrelas.",
|
||||
paras: [
|
||||
"A barrinha por cima das fotos, na grelha e no Revelar: Todas, Escolhidas, Sem marca, Sem rejeitadas, Rejeitadas, estrelas e cores. Combinam.",
|
||||
"As estrelas querem dizer pelo menos essa. Carregar outra vez na estrela acesa apaga o filtro. A cor faz o mesmo.",
|
||||
"Na tira do Revelar não há envio nem «sem jogador». Isso fica na grelha.",
|
||||
"A foto que tens aberta continua na tira mesmo que não passe no filtro. Limpar filtro repõe a grelha e a tira.",
|
||||
],
|
||||
},
|
||||
revelar: {
|
||||
title: "Revelar",
|
||||
paras: [
|
||||
"As setas mudam de foto. A barra \\ troca o antes e o depois. Z vê a 100% e, nessa vista, arrastas para te deslocares.",
|
||||
"Ctrl ou Cmd+Z anula. Com Shift, ou Ctrl ou Cmd+Y, refaz.",
|
||||
"G volta à grelha nesta foto. E abre a lupa. Ctrl ou Cmd com Alt e 1 faz o mesmo que G.",
|
||||
"R abre o recorte. W é o conta-gotas: clicas numa zona que devia ser cinzenta ou branca. Shift+A aplica o automático.",
|
||||
"Ctrl ou Cmd+A, aqui, seleciona as fotos da tira.",
|
||||
],
|
||||
},
|
||||
recorte: {
|
||||
title: "Recorte",
|
||||
caption: "Cantos e lados mudam o tamanho. Por dentro moves o recorte. Por fora rodas a foto.",
|
||||
paras: [
|
||||
"Enter conclui e Esc cancela. Ctrl ou Cmd com Alt e R repõe o recorte e o ângulo.",
|
||||
"Auto recorta à volta de quem a foto é: a bola e quem a disputa, ou o grupo principal, sem cortar um corpo a meio.",
|
||||
"Nivelar endireita pelo horizonte ou por uma linha vertical. Se não houver uma linha clara, moves o ângulo.",
|
||||
],
|
||||
},
|
||||
sincronizar: {
|
||||
title: "Sincronizar ajustes",
|
||||
caption: "Só os realces seguem. O recorte fica de fora.",
|
||||
paras: [
|
||||
"Na tira, Shift seleciona de uma foto até à outra. Ctrl ou Cmd junta ou tira uma.",
|
||||
"Sincronizar ajustes copia o que estiver marcado, da foto activa para as outras seleccionadas.",
|
||||
"Em Básico podes desmarcar o grupo e deixar só um ajuste, por exemplo os realces. O recorte não vai até o marcares.",
|
||||
"Uma foto que já tenha sido enviada volta a sair para esse destino cerca de um minuto depois da última alteração, com o mesmo nome, e substitui o ficheiro. A cópia dos originais não volta a sair.",
|
||||
],
|
||||
},
|
||||
envio: {
|
||||
title: "Enviar",
|
||||
paras: [
|
||||
"Selecionas as fotos e o destino. Podes mandar as selecionadas, só as melhores do jogo, ou o resto.",
|
||||
"O resto são as outras escolhidas e as outras fotos das mesmas sequências. As melhores não se repetem. Rejeitadas nunca vão.",
|
||||
"As melhores são momentos de jogo, nítidas e espalhadas pelo tempo, sem repetidas. Numa sequência fica a de frente e com os olhos abertos, quando dá para distinguir. As que têm estrelas passam à frente.",
|
||||
"Enviar de novo manda outra vez as que esse destino já tinha recebido.",
|
||||
],
|
||||
},
|
||||
ligacao: {
|
||||
title: "Sem ligação",
|
||||
paras: [
|
||||
"Sem rede vês as pré-visualizações e editas. A alteração fica neste computador e segue quando a ligação voltar.",
|
||||
"Podes deixar o original neste computador. Sobe uma pré-visualização, e o ficheiro grande só vai quando for preciso: ver a 100% ou um envio feito no servidor.",
|
||||
],
|
||||
},
|
||||
chegada: {
|
||||
title: "Quando a foto chega",
|
||||
paras: [
|
||||
"As fotos que chegam por FTP ou pelo ingest da app são editadas ao chegar (recorte, nivelar, tom) e as melhores de cada sequência ficam escolhidas. Tudo pode ser desfeito no Revelar. Fotos importadas à mão não são tocadas.",
|
||||
"No teu computador, os nomes das pessoas só ficam guardados quando o evento tem adversário. Num estágio ou numa reportagem, identificar caras fica no servidor.",
|
||||
],
|
||||
},
|
||||
},
|
||||
modules: {
|
||||
crop: "Recorte",
|
||||
basic: "Básico",
|
||||
|
||||
@@ -10,14 +10,14 @@ const COLORS = ["RED", "YELLOW", "GREEN", "BLUE", "PURPLE"] as const satisfies r
|
||||
const chip = (on: boolean) => (on ? "font-semibold text-ink" : "text-faint hover:text-muted");
|
||||
|
||||
/**
|
||||
* Photo Mechanic / Lightroom style filter bar: flag, stars (at least), colour, delivery state and photos without
|
||||
* players, all combinable. Clicking an active stars or colour choice again turns it off.
|
||||
* Flag, stars (at least) and colour, plus delivery and photos without players on the grid. All combinable.
|
||||
* The filmstrip uses `compact`: flag, stars and colour only. Clicking an active stars or colour choice again turns it off.
|
||||
*/
|
||||
export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryFilter) => void }) {
|
||||
const { filter: f, onChange } = props;
|
||||
export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryFilter) => void; compact?: boolean }) {
|
||||
const { filter: f, onChange, compact = false } = props;
|
||||
const set = (patch: Partial<LibraryFilter>) => onChange({ ...f, ...patch });
|
||||
return (
|
||||
<div role="group" aria-label={t.filter} className="flex flex-wrap items-center gap-x-3 gap-y-1">
|
||||
<div role="group" aria-label={t.filter} className={`flex items-center gap-x-3 gap-y-1 ${compact ? "flex-nowrap" : "flex-wrap"}`}>
|
||||
<span className="text-faint">{t.filter}:</span>
|
||||
{FLAGS.map((flag) => (
|
||||
<button key={flag} onClick={() => set({ flag })} aria-pressed={f.flag === flag} className={chip(f.flag === flag)}>
|
||||
@@ -52,7 +52,8 @@ export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryF
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
<span aria-hidden="true" className="text-line">|</span>
|
||||
{!compact && <span aria-hidden="true" className="text-line">|</span>}
|
||||
{!compact && (
|
||||
<label className="flex items-center gap-1">
|
||||
<span className="text-faint">{t.deliveryFilter}</span>
|
||||
<select
|
||||
@@ -67,9 +68,12 @@ export function FilterBar(props: { filter: LibraryFilter; onChange: (f: LibraryF
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
{!compact && (
|
||||
<button onClick={() => set({ noPlayers: !f.noPlayers })} aria-pressed={f.noPlayers} className={chip(f.noPlayers)}>
|
||||
{t.noPlayersFilter}
|
||||
</button>
|
||||
)}
|
||||
{!isAll(f) && (
|
||||
<button onClick={() => onChange(ALL_PHOTOS)} className="text-accent hover:underline">
|
||||
{t.clearFilter}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { type DeliveryTarget, hasRole } from "@photoreport/sdk";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
||||
import { useLocation, useNavigate, useParams } from "react-router";
|
||||
import { useAuth } from "../auth.js";
|
||||
import { HelpLink } from "../components/HelpLink.js";
|
||||
import { type EngineModule, loadEngine } from "../develop/engine.js";
|
||||
import { DevelopPanels, Section, Slider } from "../develop/Panels.js";
|
||||
import { type Crop, cropOf, DevelopSession, localOutbox } from "../develop/session.js";
|
||||
@@ -11,12 +12,13 @@ import { commandsFrom, queueSync } from "../develop/copySettings.js";
|
||||
import { clampUnit, constrainRotated, fitAspect, GUIDES, type Guide, rotateAspect } from "../develop/crop.js";
|
||||
import { engineAuto, Viewer } from "../develop/Viewer.js";
|
||||
import { IptcInfo } from "../library/IptcInfo.js";
|
||||
import { activePhoto, savedFilter, setActivePhoto } from "../library/active.js";
|
||||
import { activePhoto, savedFilter, saveFilter, setActivePhoto } from "../library/active.js";
|
||||
import { FilterBar } from "../library/FilterBar.js";
|
||||
import { cache } from "../offline/cache.js";
|
||||
import { localPhotos } from "../offline/local.js";
|
||||
import { isNetworkError, offlineQueue } from "../offline/queue.js";
|
||||
import { patchPhotos, useOfflineSync } from "../offline/sync.js";
|
||||
import { applyPatch, isMac, type LibraryFilter, matchesFilter, patchForKey, pmPatchForKey } from "../library/store.js";
|
||||
import { ALL_PHOTOS, applyPatch, isMac, type LibraryFilter, matchesFilter, patchForKey, pmPatchForKey } from "../library/store.js";
|
||||
import { t } from "../i18n.js";
|
||||
import { useLibraryLive } from "../library/realtime.js";
|
||||
import { isDesktop, localOriginalToView, prefs } from "../platform.js";
|
||||
@@ -151,9 +153,18 @@ export function DevelopPage() {
|
||||
const here = localPhotos.list().filter((p) => (scope === "inbox" ? p.eventId === null : p.eventId === scope) && !all.some((q) => q.sha256 === p.sha256));
|
||||
return here.length ? [...all, ...here].sort((a, b) => (a.capturedAt ?? "").localeCompare(b.capturedAt ?? "")) : all;
|
||||
}, [all, localVersion, scope]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
// The filmstrip follows the library's filter, like Lightroom's (the open photo stays even if it doesn't match).
|
||||
const filterJson = JSON.stringify(savedFilter(orgId));
|
||||
const filter = useMemo(() => JSON.parse(filterJson) as LibraryFilter, [filterJson]);
|
||||
// The filmstrip follows the same filter as the grid. The open photo stays even when it does not match.
|
||||
const [filter, setFilter] = useState<LibraryFilter>(() => (orgId ? savedFilter(orgId) : ALL_PHOTOS));
|
||||
useEffect(() => {
|
||||
if (orgId) setFilter(savedFilter(orgId));
|
||||
}, [orgId]);
|
||||
const changeFilter = useCallback(
|
||||
(next: LibraryFilter) => {
|
||||
setFilter(next);
|
||||
saveFilter(orgId, next);
|
||||
},
|
||||
[orgId],
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!withLocal) return;
|
||||
const ready = withLocal.filter((p) => p.status === "READY");
|
||||
@@ -686,9 +697,9 @@ export function DevelopPage() {
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<HelpLink section="recorte" label={t.help.recorte.title} />
|
||||
</label>
|
||||
</div>
|
||||
<p className="mb-2 text-[11px] text-faint">{t.dev.cropHelp}</p>
|
||||
{angle && (
|
||||
<div className="flex items-end gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
@@ -777,6 +788,10 @@ export function DevelopPage() {
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div className="flex h-7 shrink-0 items-center gap-2 overflow-x-auto border-t border-line bg-chrome px-2 text-[11px]">
|
||||
<FilterBar compact filter={filter} onChange={changeFilter} />
|
||||
<HelpLink section="filtro" label={t.help.filtro.title} />
|
||||
</div>
|
||||
<div ref={strip} className="flex h-[92px] shrink-0 gap-1 overflow-x-auto border-t border-line bg-chrome p-1.5" aria-label="Fotos do evento">
|
||||
{photos.map((p) => (
|
||||
<button
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { HelpLink } from "../components/HelpLink.js";
|
||||
import { HelpPage } from "./HelpPage.js";
|
||||
|
||||
describe("help", () => {
|
||||
it("teaches the crop from the guide, with the screen it belongs to", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<HelpPage />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
expect(screen.getByRole("heading", { name: "Recorte" })).toBeTruthy();
|
||||
expect(screen.getByText(/Shift mantém a forma/)).toBeTruthy();
|
||||
expect(screen.getByText("Bloquear")).toBeTruthy();
|
||||
expect(screen.getByText(/Só os realces seguem/)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("opens a chapter from the small i", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<HelpLink section="recorte" label="Recorte" />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
expect(screen.getByRole("link", { name: "Ajuda: Recorte" }).getAttribute("href")).toBe("/help#recorte");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { Link, useLocation } from "react-router";
|
||||
import { t } from "../i18n.js";
|
||||
import { FilterBar } from "../library/FilterBar.js";
|
||||
import { ALL_PHOTOS } from "../library/store.js";
|
||||
import { PageHeader } from "./Shell.js";
|
||||
|
||||
const CHAPTERS = ["biblioteca", "filtro", "revelar", "recorte", "sincronizar", "envio", "ligacao", "chegada"] as const;
|
||||
|
||||
type ChapterId = (typeof CHAPTERS)[number];
|
||||
|
||||
const HANDLES = [
|
||||
"left-0 top-0",
|
||||
"left-1/2 top-0 -translate-x-1/2",
|
||||
"right-0 top-0",
|
||||
"left-0 top-1/2 -translate-y-1/2",
|
||||
"right-0 top-1/2 -translate-y-1/2",
|
||||
"bottom-0 left-0",
|
||||
"bottom-0 left-1/2 -translate-x-1/2",
|
||||
"bottom-0 right-0",
|
||||
];
|
||||
|
||||
function chapter(id: ChapterId) {
|
||||
return t.help[id];
|
||||
}
|
||||
|
||||
/** The crop tool as it sits in Revelar, so the guide shows the screen instead of only describing it. */
|
||||
function CropExample() {
|
||||
return (
|
||||
<figure className="my-3 max-w-md border border-line bg-[#1a1a1b]">
|
||||
<div className="relative aspect-[3/2] w-full bg-[#2a2c28]">
|
||||
<div className="absolute inset-[18%] border border-white/80">
|
||||
{HANDLES.map((pos) => (
|
||||
<span key={pos} className={`absolute h-1.5 w-1.5 bg-white ${pos}`} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-1 border-t border-line bg-chrome p-2 text-[11px]">
|
||||
<span className="border border-black bg-cell-on px-2 py-1 text-ink">{t.dev.cropLock}</span>
|
||||
<span className="border border-black bg-cell px-2 py-1 text-muted">{t.dev.cropSwap}</span>
|
||||
<span className="border border-black bg-cell px-2 py-1 text-muted">{t.dev.cropReset}</span>
|
||||
<span className="ml-auto text-faint">{t.dev.guides}</span>
|
||||
<span className="border border-black bg-cell px-2 py-1 text-ink">{t.dev.guideNames.grid}</span>
|
||||
</div>
|
||||
<figcaption className="px-2 py-1 text-[11px] text-faint">{t.help.recorte.caption}</figcaption>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
function FilterExample() {
|
||||
return (
|
||||
<figure className="my-3 overflow-x-auto border border-line bg-chrome px-2 py-1.5 text-[11px]">
|
||||
<div className="pointer-events-none">
|
||||
<FilterBar compact filter={{ ...ALL_PHOTOS, flag: "PICK", minRating: 2 }} onChange={() => {}} />
|
||||
</div>
|
||||
<figcaption className="pt-1 text-faint">{t.help.filtro.caption}</figcaption>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
function SyncExample() {
|
||||
const rows: { id: keyof typeof t.dev.labels; on: boolean }[] = [
|
||||
{ id: "light.exposure", on: false },
|
||||
{ id: "light.contrast", on: false },
|
||||
{ id: "light.highlights", on: true },
|
||||
{ id: "light.shadows", on: false },
|
||||
{ id: "light.whites", on: false },
|
||||
{ id: "light.blacks", on: false },
|
||||
];
|
||||
return (
|
||||
<figure className="my-3 w-56 border border-black bg-raised p-2 text-[12px] text-ink">
|
||||
<p>{t.modules.basic}</p>
|
||||
<ul className="mt-1 flex flex-col gap-1 pl-4">
|
||||
{rows.map((row) => (
|
||||
<li key={row.id} className="flex items-center gap-2">
|
||||
<span aria-hidden="true">{row.on ? "☑" : "☐"}</span>
|
||||
{t.dev.labels[row.id]}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="mt-2 flex items-center gap-2">
|
||||
<span aria-hidden="true">☐</span>
|
||||
{t.modules.crop}
|
||||
</p>
|
||||
<figcaption className="mt-2 text-[11px] text-faint">{t.help.sincronizar.caption}</figcaption>
|
||||
</figure>
|
||||
);
|
||||
}
|
||||
|
||||
const FIGURES: Partial<Record<ChapterId, () => ReactNode>> = {
|
||||
filtro: FilterExample,
|
||||
recorte: CropExample,
|
||||
sincronizar: SyncExample,
|
||||
};
|
||||
|
||||
/** The guide: one chapter per job, with the screen it belongs to. */
|
||||
export function HelpPage() {
|
||||
const { hash } = useLocation();
|
||||
useEffect(() => {
|
||||
const id = hash.replace(/^#/, "");
|
||||
if (id) document.getElementById(id)?.scrollIntoView();
|
||||
}, [hash]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title={t.help.title} />
|
||||
<div className="mx-auto max-w-3xl px-6 py-6">
|
||||
<p className="text-sm text-muted">{t.help.intro}</p>
|
||||
<nav aria-label={t.help.title} className="mt-4 flex flex-wrap gap-x-4 gap-y-1 text-[13px]">
|
||||
{CHAPTERS.map((id) => (
|
||||
<Link key={id} to={`/help#${id}`} className="text-faint hover:text-ink">
|
||||
{chapter(id).title}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
{CHAPTERS.map((id) => {
|
||||
const item = chapter(id);
|
||||
const Figure = FIGURES[id];
|
||||
return (
|
||||
<section key={id} id={id} className="mt-8 scroll-mt-6 border-t border-line pt-4">
|
||||
<h2 className="text-sm font-semibold">{item.title}</h2>
|
||||
{Figure && <Figure />}
|
||||
<div className="mt-2 flex flex-col gap-2 text-[13px] leading-relaxed text-muted">
|
||||
{id === "recorte" && <p>{t.dev.cropHelp}</p>}
|
||||
{item.paras.map((para) => (
|
||||
<p key={para}>{para}</p>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -126,6 +126,9 @@ export function Shell() {
|
||||
{t.members}
|
||||
</NavLink>
|
||||
)}
|
||||
<NavLink to="/help" className="block px-3 py-2 hover:bg-raised">
|
||||
{t.help.menu}
|
||||
</NavLink>
|
||||
<NavLink to="/preferences" className="block px-3 py-2 hover:bg-raised">
|
||||
{t.preferences}
|
||||
</NavLink>
|
||||
|
||||
@@ -33,16 +33,18 @@ Following the AP and NPPA codes:
|
||||
mid-thigh when the foot already leaves the photo. The face is big (a median face of 14% of the frame height)
|
||||
near the top.
|
||||
- **"full"** keeps whole bodies when they fit: Peter's usual crop, about two thirds of the frame.
|
||||
- **Reportage** always keeps a whole hand and a whole foot. The sports framing on the event is ignored.
|
||||
- **Reportage** keeps a whole hand and a whole foot when they are in the photo. The sports framing on the event
|
||||
is ignored. A person the frame has already cut in half is not pulled into the subject: half a body at the
|
||||
edge is background, and the crop leaves it out whenever it can.
|
||||
- **Never cut:** heads, faces, a hand or a foot that is whole in the photo, hands holding the ball, the ball itself.
|
||||
A person who is in the crop keeps their head, including someone a little less sharp stood in the shade. In
|
||||
reportage the people of a conversation are one subject, so the crop is built around all of them.
|
||||
- **Limbs:** if a body has to be cut, cut mid-limb (mid-thigh, mid-shin, mid-forearm), never at a joint (ankle,
|
||||
knee, hip, wrist, elbow, neck). The engine estimates joints from the body box and avoids crop edges there.
|
||||
- **Feet and hands:** a foot or a hand that is whole in the photo stays in the crop. A foot keeps a little
|
||||
ground under the sole. Cutting the shoe, the ankle or a hand just to fill the frame is not allowed. A leg is
|
||||
cut only when the foot already leaves the photo, or the whole body cannot fit: mid-thigh, or (with a ball in
|
||||
play) mid-shin, never at a joint, and never below the ball.
|
||||
ground under the sole. Cutting the shoe, the ankle or a hand just to fill the frame is not allowed. When the
|
||||
foot already leaves the photo, the crop ends mid-shin or mid-thigh. It does not stop on the sock. Never at a
|
||||
joint, and never through the ball.
|
||||
- **Edges:** no slivers of other in-focus people at the crop edge: either in, or out. Blurred foreground and
|
||||
background people don't count. In reportage this is absolute for anyone still reasonably sharp: the crop
|
||||
keeps their head, and the primary crop keeps their feet when those feet are in the photo. A half or a
|
||||
@@ -51,7 +53,8 @@ Following the AP and NPPA codes:
|
||||
beat a whole figure standing in the same photo. The taller person, closer to the camera, stays in the frame
|
||||
even when someone behind them is a little sharper.
|
||||
- **Stray limbs:** a hand or a foot of someone who is not the subject, and nothing more of them, is cropped out
|
||||
so the frame stays clean. A whole other person is not that: they stay in or go out, they are not sliced.
|
||||
so the frame stays clean. So is a person the photo already cuts in half at the frame edge, when they are not
|
||||
the subject. A whole other person is not that: they stay in or go out, they are not sliced.
|
||||
- **Headroom:** heads a little below the top edge, not touching it, not floating in empty space.
|
||||
- **Vertical placement:** the upper body (chest, faces) a little above the middle of the crop, never the knees.
|
||||
Little or no empty pitch or floor under the feet: when the crop is taller than the subject, the spare height
|
||||
|
||||
Reference in new issue
Block a user