Write ratings, keywords, hierarchy and IPTC to XMP

Sidecars and JPEG exports now carry xmp:Rating, xmp:Label, dc:subject and
lr:hierarchicalSubject plus the IPTC core, and importing a sidecar applies its
cataloguing fields independently of its develop settings. Hierarchical keywords
keep leaf terms in the flat list, so search and filters are unchanged.
This commit is contained in:
2026-12-02 03:30:57 +00:00
parent fa0a7e64ef
commit 7f0838156b
11 changed files with 808 additions and 27 deletions
+4
View File
@@ -157,6 +157,8 @@ interface Props {
onVirtualCopy: () => void;
metadataPresets: MetadataPreset[];
keywordLibrary: string[];
/** Hierarchical paths already in the library, for metadata suggestions. */
keywordPathLibrary?: string[];
onSaveSnapshot: (name: string) => void;
onRestoreSnapshot: (snapshot: Snapshot) => void;
onDeleteSnapshot: (snapshot: Snapshot) => void;
@@ -191,6 +193,7 @@ export default function Develop({
onVirtualCopy,
metadataPresets,
keywordLibrary,
keywordPathLibrary = [],
onSaveSnapshot,
onRestoreSnapshot,
onDeleteSnapshot,
@@ -1773,6 +1776,7 @@ export default function Develop({
onUpdate={(patch) => onUpdate(photo.id, patch)}
presets={metadataPresets}
keywordLibrary={keywordLibrary}
keywordPathLibrary={keywordPathLibrary}
onSavePreset={onSaveMetadataPreset}
onDeletePreset={onDeleteMetadataPreset}
/>
+107 -3
View File
@@ -11,6 +11,7 @@ import {
} from '../lib/denoiseModels';
import type { DenoiseProgress } from '../lib/api';
import { clamp } from '../lib/curves';
import { addKeywordPath, removeKeywordPath } from '../lib/keywords';
import type {
CurveChannel,
Edits,
@@ -2662,6 +2663,7 @@ export function MetadataPanel({
onUpdate,
presets = [],
keywordLibrary = [],
keywordPathLibrary = [],
onSavePreset,
onDeletePreset,
}: {
@@ -2670,6 +2672,8 @@ export function MetadataPanel({
onUpdate?: (patch: Partial<PhotoRecord>) => void;
presets?: MetadataPreset[];
keywordLibrary?: string[];
/** Existing hierarchical paths in the library, offered as suggestions. */
keywordPathLibrary?: string[];
onSavePreset?: (preset: Omit<MetadataPreset, 'id'>) => void;
onDeletePreset?: (id: string) => void;
}) {
@@ -2705,11 +2709,21 @@ export function MetadataPanel({
const patch = (next: Partial<PhotoRecord>) => onUpdate?.(next);
/**
* One entry point for both kinds of tag: a plain word stays flat, and
* `Nature > Birds` records the path and its ancestors. The leaf is added to
* `keywords` either way, so search and filters keep working on flat terms.
*/
const addKeyword = (raw?: string) => {
const value = (raw ?? keyword).trim().replace(/,$/, '');
if (!value) return;
const exists = photo.keywords.some((word) => word.toLowerCase() === value.toLowerCase());
if (!exists) patch({ keywords: [...photo.keywords, value.slice(0, 48)] });
patch(
addKeywordPath(
{ keywords: photo.keywords, keywordPaths: photo.keywordPaths ?? [] },
value,
/[>/|]/.test(value),
),
);
setKeyword('');
};
@@ -2717,6 +2731,19 @@ export function MetadataPanel({
patch({ keywords: photo.keywords.filter((item) => item !== word) });
};
const removePath = (path: string) => {
patch(
removeKeywordPath(
{ keywords: photo.keywords, keywordPaths: photo.keywordPaths ?? [] },
path,
),
);
};
const patchIptc = (field: keyof NonNullable<PhotoRecord['iptc']>, value: string) => {
patch({ iptc: { ...photo.iptc, [field]: value } });
};
const applyPreset = (id: string) => {
setPresetId(id);
const preset = presets.find((item) => item.id === id);
@@ -2795,11 +2822,32 @@ export function MetadataPanel({
</button>
))}
</div>
{photo.keywordPaths?.length ? (
<>
<div className="metadata-keywords-head">
<span>Keyword paths</span>
<span className="muted small">{photo.keywordPaths.length}</span>
</div>
<div className="keyword-chips">
{photo.keywordPaths.map((path) => (
<button
key={path}
className="keyword-chip"
onClick={() => removePath(path)}
title="Remove this path and everything under it"
>
{path} <span aria-hidden="true">×</span>
</button>
))}
</div>
</>
) : null}
<div className="keyword-add">
<input
value={keyword}
list="lumen-keyword-library"
placeholder="Add keyword…"
placeholder="Add keyword, or Nature > Birds…"
onChange={(e) => setKeyword(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ',') {
@@ -2816,9 +2864,65 @@ export function MetadataPanel({
{keywordLibrary.map((word) => (
<option key={word} value={word} />
))}
{keywordPathLibrary.map((path) => (
<option key={`path:${path}`} value={path} />
))}
</datalist>
</div>
<div className="metadata-keywords-head">
<span>IPTC</span>
</div>
<label className="field">
<span>Headline</span>
<input
value={photo.iptc?.headline ?? ''}
placeholder="Who, what, where"
onChange={(e) => patchIptc('headline', e.target.value)}
disabled={!onUpdate}
/>
</label>
<div className="field-row">
<label className="field">
<span>Credit</span>
<input
value={photo.iptc?.credit ?? ''}
placeholder="Photographer credit"
onChange={(e) => patchIptc('credit', e.target.value)}
disabled={!onUpdate}
/>
</label>
<label className="field">
<span>Source</span>
<input
value={photo.iptc?.source ?? ''}
placeholder="Agency or client"
onChange={(e) => patchIptc('source', e.target.value)}
disabled={!onUpdate}
/>
</label>
</div>
<div className="field-row">
<label className="field">
<span>City</span>
<input
value={photo.iptc?.city ?? ''}
placeholder="City"
onChange={(e) => patchIptc('city', e.target.value)}
disabled={!onUpdate}
/>
</label>
<label className="field">
<span>Country</span>
<input
value={photo.iptc?.country ?? ''}
placeholder="Country"
onChange={(e) => patchIptc('country', e.target.value)}
disabled={!onUpdate}
/>
</label>
</div>
<div className="metadata-presets">
<select value={presetId} onChange={(e) => applyPreset(e.target.value)} disabled={!presets.length || !onUpdate}>
<option value="">Apply metadata preset…</option>