Skip to content

Lightroom import gives the photos it adds the catalog's settings and history, not their file's XMP - #731

Merged
emmertex merged 1 commit into
emmertex:mainfrom
clydecbrown:classic/fix/lr-import-embedded-edits
Nov 1, 2026
Merged

emmertex merged 1 commit into
emmertex:mainfrom
clydecbrown:classic/fix/lr-import-embedded-edits

Conversation

@clydecbrown

Copy link
Copy Markdown
Collaborator

Fixes #730

Port of storytold/lightcraft PR #3435 (storytold/lightcraft issue #3434): storytold/lightcraft#3435

Problem

Importing a Lightroom Classic catalog into a new, empty library gave a raw whose file holds develop settings in XMP
(embedded in a DNG, or a .xmp sidecar) those settings instead of the catalog's, dropped its Lightroom history and
snapshots, and counted it under preservedExistingEdits. Any edit made in Lightroom since the metadata was last
saved to the file was lost. A photo that had only been browsed (Local) and not touched since was treated the same
way.

Cause: the import first adds the originals to the library, and adding a raw (or browsing it earlier) merges the
settings from its XMP, which sets the photo's edited time. apply_prepared then found that photo by path, saw
edits, and set keep_develop, which here also skips the catalog's history and snapshots.

Change

Ported by hand from the upstream PR's two commits; the app keeps the import report in import.rs here, and its
keep_develop also guards history and snapshots, so those come back with the settings.

  • crates/engine/src/lightroom_catalog.rs: apply_prepared collects the photos its own add step created or
    promoted from Local (files.imported, minus the promoted ones changed after browsing) and never treats those as
    existing, so keep_develop applies only to photos with changes of the library's own. A Local record still
    untouched since browsing counts as new too when its original is offline (missing originals skip the add step).
    For these photos the catalog's settings start from the camera's defaults, not from what the file's XMP or a
    default import preset gave the photo: Lightroom leaves some settings at zero out of its develop text (Clarity,
    Texture), so a value only the file or preset holds would otherwise survive. When the catalog's develop text can't be read,
    the photo keeps what it had, with a warning, instead of being left on the camera's defaults.
  • crates/engine/src/import.rs: ImportReport gains promoted_changed (not serialized): the Local records among
    imported that untouched_local() says were changed after browsing, read before the promotion is committed.
  • docs/lightroom-catalog-import.md states the rule; What's New and changelog entries.

Not in this PR: "changed after browsing" is untouched_local()'s whole-record test, so a browsed photo whose
only change is a rating or keyword still keeps the settings it read from its file (conservative: nothing is lost).
updateExisting: true over a photo with library edits still applies the catalog's settings on top of them, as
before; a catalog row with no develop settings leaves the file's in place. A new virtual copy still starts from its
master's settings, so a value the copy's settings leave out comes from the master, and a catalog photo whose
original has the same bytes as another record starts from that record's settings (both older than this PR). A raw
given a default import preset keeps it as its import look, so Reset Edits returns to that preset, as before. Why a JPEG
with the same embedded settings was spared before was not traced.

How it was checked

  • cargo xtask ci --fast, cargo xtask sil and cargo test --workspace --no-fail-fast pass on this
    branch, except three lcc-engine peers tests and one lcc-updater zip-swap test that fail the same way on main
    on this Mac.
  • New tests, each seen failing with its rule reverted:
    • a_photo_this_import_adds_takes_the_catalogs_settings_over_its_files_xmp: a DNG with embedded XMP and a DNG with
      a sidecar, both saying Dehaze 0 and Clarity +20, imported from a catalog that says Dehaze −50 with two history
      steps, and a default raw import preset setting Texture 12. With the fix reverted, preservedExistingEdits is 2
      (not 0) and no history comes in; without the camera-defaults reset, Clarity stays 20.
    • a_browsed_photo_keeps_only_edits_made_after_browsing: a real .lrcat import (catalog Dehaze −50 and one
      history step) over a Local record holding settings read at browse time, untouched or edited after browsing,
      with its original present or offline. Counting every promoted record as changed fails the untouched case
      (preserved 1, not 0); counting none fails the edited case (preserved 0, not 1); without the untouched_local()
      check at apply time the offline untouched case fails (preserved 1, not 0); without the camera-defaults reset a
      Clarity the catalog leaves out stays 15.
    • unreadable_catalog_settings_leave_a_new_photos_file_settings: a DNG whose embedded XMP sets Clarity +20, with a
      default raw import preset setting Texture 12, from a catalog whose develop text can't be read: both values stay,
      with a warning. Resetting to the camera's defaults without checking the text first leaves Clarity at 0.
  • Ran the CLI on a Lightroom Classic 15.3 catalog of 6 photos (4 DNGs, a CR3 with a sidecar, a JPEG), each saved
    to file and then edited once more (Dehaze −50). Before: preservedExistingEdits 5, historySteps 3, and the 5 raws
    had Dehaze 0 and no history. After, into an empty library and into one with the folder browsed first:
    preservedExistingEdits 0, historySteps 18, all six with Dehaze −50, Exposure +1 and 3 history steps. Importing
    the catalog again keeps all six (preservedExistingEdits 6, nothing added).

Acceptance criteria

  • AC-1: Importing a catalog into an empty library gives every photo the catalog's develop settings and edit
    history, whatever XMP its file embeds or its sidecar holds; the report's preservedExistingEdits is 0. —
    test a_photo_this_import_adds_takes_the_catalogs_settings_over_its_files_xmp (seen failing with the fix
    reverted)
  • AC-2: A photo that was in the library and edited there before the import still keeps its edits unless
    updateExisting is true (today's rule for real existing edits). — existing test
    preserves_existing_edits_and_rejects_invalid_structure_before_mutation, and the edited cases of
    a_browsed_photo_keeps_only_edits_made_after_browsing
  • AC-3: A photo the library already had, unedited, takes the catalog's settings, as today. — unchanged:
    keep_develop still needs edited set (lightroom_catalog.rs)
  • AC-4: A photo that was only browsed (Local) and not changed since takes the catalog's develop settings and
    history too, though browsing read settings from its file's XMP, also when its original is offline; one changed
    after browsing keeps its edits, as in AC-2. — test a_browsed_photo_keeps_only_edits_made_after_browsing
    (each case seen failing with its rule reverted)
  • AC-5: For a photo the import treats as new (AC-1, AC-4), a setting the catalog's develop text leaves out
    (Lightroom omits Clarity, Texture and others at zero) comes from the camera's defaults, not from the file's XMP
    or a default import preset; a catalog row with no develop text leaves the photo's settings as they are. —
    Clarity and Texture assertions in both tests (Clarity seen failing without the reset); the reset is skipped
    when the row has no develop text or it can't be read (lightroom_catalog.rs; test
    unreadable_catalog_settings_leave_a_new_photos_file_settings, seen failing without that check)

Merging

  • Upstream: this is storytold/lightcraft PR #3435, still open there; the commit carries UPSTREAM-PR:.
  • Existing edits and libraries: unchanged. Only photos a catalog import adds, or promotes from Local untouched,
    get different settings: the catalog's.
  • New dependencies, unsafe, build scripts, network access, spawned processes, deleted files, CI or xtask gate
    changes:
    none.

Sources: own design, ported from storytold/lightcraft PR #3435.

🤖 Generated with Claude Code

…e XMP read from a file it adds or a browse left untouched

Importing a catalog first adds the originals, and adding (or an earlier browse) merges the develop
settings from the file's XMP and sets `edited`. `apply_prepared` then took those for edits the
library already had and kept them over the catalog's (`keep_develop`), which also skipped the
catalog's history and snapshots, counting the photo under `preservedExistingEdits`. An edit made in
Lightroom since the file's XMP was saved was lost.

The import now never counts photos its own add step created, or Local ones untouched since
browsing (judged again at apply time, for offline originals), as existing:
`ImportReport.promoted_changed` (not serialized) lists the promoted Local records changed after
browsing, and only those, with records the library had before, keep their edits. For the others the
catalog's settings start from the camera's defaults, since Lightroom leaves settings at zero
(Clarity, Texture) out of its develop text; when that text can't be read, the photo keeps what it
had.

Sources: own design, ported from storytold#3435.

UPSTREAM-PR: storytold#3435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@emmertex
emmertex merged commit 6337280 into emmertex:main Nov 1, 2026
5 checks passed
@clydecbrown
clydecbrown deleted the classic/fix/lr-import-embedded-edits branch November 1, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lightroom import gives the photos it adds the catalog's settings and history, not their file's XMP

2 participants