Repository navigation
Export: a photo's cancel is polled between its stages, a graphic watermark is prepared once per size, and an 8-bit export no longer stacks whole-image copies - #1848
Merged
emmertex merged 8 commits intoDec 2, 2026
Conversation
…ng and watermark floor to the preview A full-size export wider than 4096 px is previewed at 4096 px, by replacing its resize. Output sharpening (a mask of 0.7 to 1.0 pixels) and the watermark's 6 px smallest text size and shadow offset are in the file's pixels, but the preview applied them unscaled to the smaller picture, so a preview of an 8192 px file showed twice the sharpening radius and twice the minimum text size the file has, while the manual says the file matches the preview. prepare_preview now records the preview's size over the file's (1 for anything not capped), and preview_until finishes the 8-bit and the float rendition with it: the sharpening radius is scaled (never above the file's, never below a one-tap mask that changes nothing) and the watermark's floor is scaled through the existing floor-scale parameter. A scale of 1, an export and every other caller are unchanged. The manual's Preview line says a file over 4096 px is previewed at 4096 px. Tests: the radius and its edge cases (scale 1, 0.5, above 1, NaN, infinite, 0, negative), sharpening changing less at half size and not at all far below a pixel, the float path alike; the watermark floor kept as the same share of the picture at 8 bits and in float; and the scale prepare_preview records below, at and above the 4096 px cap (4095, 4096, 4097, 8192), for a copied original and for an export. Each fails with the old behaviour put back: the radius ignoring the scale, the watermark ignoring it, and the scale not recorded. Manual: output/export.mdx Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Problem: cancelling an Original or DNG export of a large file, or a photo whose JPEG is fitted to a file size limit, ran the photo to the end of its stages. The whole-file read was already cancellable, but the location checks, the raw decode, the colour step and the DNG write ran back to back with no poll, and so did the sharpening/watermark pass, each full-size encode of a size fit and the stages of a gain map or HDR encode. Each is seconds on a large photo. Change: Work::File polls the cancel after the read, between the location checks, and before the decode, the colour step and the write. The 8-bit, deep and gain map encoders take the cancel and poll after the sharpening/watermark pass, before the encode call, and before each full-size encode of a size fit. An encoder call itself is never interrupted. The public encoders pass a check that never cancels. Tests: a cancel raised while the file is read ends an Original export (that would be refused for its location) and a DNG export (of a file that is no raw) as cancelled instead of running the next stage; a DNG export polls at every stage and a cancel at any of its polls ends it; a cancel raised during the first encode of a size fit leaves the second encode unmade. All three fail with the polls removed (the Original export reports the location refusal, the fit makes its second encode, the DNG export polls only in the read). Manual: none (the Export page already says the cancel stops the export; it now stops sooner) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…by the UI thread that prepares a batch Preparing a background export builds a guard over the library's originals on the UI thread: about fifteen lookup entries per photo (the original, its sidecars in each spelling the reader accepts). On a library of 100,000 photos that took ~360 ms (350 to 379 ms over three runs), and the same guard was made for every queued export when it started. OriginalGuard::new now only lists the originals (~16 ms for the same library, mostly the pass over the catalog); the lookup by file name is made from that list by the first check or claim that needs it, which in a background export is the worker that writes the files. Adding an original drops the lookup, as it already dropped the symlink table, so one added later is still protected. Nothing about what a guard refuses changes. Measured on 251 JPEG photos, prepare_batch took 4 ms cold-cache (~17 us a photo), so the rest of the preparation, which needs the session and so cannot run on the worker, is not what held the window; the export task's header says so. Preparing lazily per lane would need the session on the lanes: left as a question (see the report). Test: making a guard indexes nothing, the first check does, an original added after it is found by the next one, and a path with no file name is not an original. It fails when the guard indexes eagerly again. Manual: none, no user-visible change beyond responsiveness (whats-new and changelog entry in the last commit) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ets makes one Every Export-dialog preview refresh asked the session for a guard over the library's originals on the UI thread (about fifteen lookup entries per photo, ~360 ms at 100,000 photos) and never read it: a preview writes nothing. And a run of several presets made one guard per preset, and, when a preset could not be prepared for a batch, one more for every photo prepared one by one. prepare_preview now prepares against an empty guard. run_presets::prepare builds one guard for the run and shares it across presets and photos, through prepare_batch_guarded and the existing prepare_guarded (the rest of run_presets.rs is untouched). Measured at 100,000 photos (three runs): building a guard 351 to 379 ms before; making one, which is all a refresh or a batch does on the UI thread after FX-232, 15 to 17 ms; a preview now makes none. Tests: a preview's prepared export protects no original and builds no guard over the catalog, an export protects the photo and builds one; a run of three presets, one of which cannot be prepared for a batch (a demo photo has no file to copy), builds one guard over the library. They fail with the preview preparing through prepare_export and with run_presets building a guard at each call (seven guards before). Manual: none, no user-visible change beyond responsiveness. whats-new and changelog entries for this group of changes are in this commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ot per photo Problem: every photo of a batch with a graphic watermark premultiplied the whole logo (16 bytes a pixel: a gigabyte at the largest logo a watermark may use, on every export lane at once) and resized it again, and for an export space other than sRGB srgb8_in rebuilt the colour matrix for every covered logo pixel. Only the logo's decode was cached. Change: scaled_logo keeps the premultiplied, resized copy for the last eight (logo, size) pairs, up to 4 million pixels each, held only while the cached logo it was made from is alive (a changed file is a new logo), and made under a lock so lanes that need the same one wait for it instead of each making it. A larger copy is made for its photo and dropped as before. srgb8_converter builds the matrix once and srgb8_in is a call of it. Output is bit-identical. Measured on one machine (a 2048 px logo at 20% of a 6000 x 4000 photo, draw_watermark, 8 runs of the test profile, quiet machine, before then after): sRGB 22.2 ms median to 7.8 ms, Display P3 224.8 ms to 29.1 ms (the first photo of a size still costs what it did, 53 ms). Peak resident size of the test process, 303 MB both times (its canvas dominates), so the gigabyte saving at the logo cap is arithmetic from the pixel size, not measured. Tests: the kept copy equals the premultiply-and-resize of the old code bit for bit at smaller, equal, larger and thin sizes, is shared by the next photo of a size, is not shared across logos or sizes, and is not kept above the size cap; the converter equals the old per-colour srgb8_in for every output space over the grey ramp and a colour grid; a changed logo file draws as the new one. These pin unchanged output, so there is no failing run of the old code: with the size or logo identity of the cache key dropped they fail (checked). Manual: none, no user-visible change except speed Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Problem: a rendered picture the encoder owned was still borrowed by it. finish_8bit cloned it whenever sharpening or a watermark applied; an opaque PNG, TIFF or WebP then repacked it to RGB in a second buffer; the PNG writer copied the samples again (to_vec) and the lossy WebP writer rebuilt them through a per-byte iterator chain, so a very large export held the picture four or five times at once. Change: the encoders take the 8-bit picture as a Cow. A render the export owns (and a preview's) is consumed: finish_8bit draws on it in place, with_alpha adds the alpha in place, and an opaque picture packs to RGB inside its own allocation (rgb_of). The gain map encoders take the same. A borrowed picture (the public encode functions) is copied where it was, as before. encode_png writes 8-bit samples as they are, and encode_webp_lossy hands RGB and RGBA samples to libwebp as they are (grey is widened as before). The TIFF encoder's premultiplied copy of a picture with alpha is a transformation, not a spare copy, and stays. Files are byte for byte the same. Measured (a 10000 x 7000 opaque picture, 280 MB as RGBA, encode_8bit with the caller holding the picture as the export did before and not after; /usr/bin/time -l maximum resident size of the test process, same machine, before then after, one run each): PNG 956 MB to 555 MB, with a watermark 1216 MB to 508 MB; TIFF 777 MB to 500 MB, with a watermark 967 MB to 501 MB; lossy WebP 1752 MB to 1161 MB, with a watermark 1890 MB to 1163 MB. Output sizes identical in each pair. Times (single runs, not a claim): PNG 1.03 s to 0.68 s, TIFF 0.48 s to 0.16 s, WebP unchanged at 13.5 s. The 512 MP case (emmertex#1477) is not measured. Tests: an owned render is finished and packed in the same allocation and gives the pixels a copy of it does; every format gives the same bytes from an owned and a borrowed picture, opaque and transparent, with and without sharpening and a watermark; PNG and lossy WebP write the same file from RGB, RGBA and widened grey samples and ignore samples past the image. They fail with the old copies put back (clone in finish_8bit and rgb_of: the allocation checks; borrowing the whole buffer in the encoders: the WebP sample-count error). Manual: none, no user-visible change except memory Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ort-preview-and-ui-thread # Conflicts: # crates/engine/src/tests_export.rs
…x-219-233-234-export-cancel-and-copies # Conflicts: # crates/engine/src/export.rs
emmertex
added a commit
to blwfish/chromaforge
that referenced
this pull request
Dec 2, 2026
The new deep-watermark test passes the floor scale that staging's draw_watermark_deep_over now takes (emmertex#1848). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1847. This branch contains #1847's commits (the two touch the same lines of
export.rs), so they show in this diff until #1847 merges; after that only this change remains. If this merges first, #1847 becomes empty.Part of #1838 (entries 11 to 13).
In short: ✕ on an export now takes effect between the stages of a large photo (not only after the whole photo), a graphic watermark's logo is premultiplied and resized once per photo size rather than for every photo, and an 8-bit export no longer holds several whole-image copies at once.
Change
/usr/bin/time -l, output sizes identical): PNG 956 MB to 555 MB (1,216 MB to 508 MB with a watermark), TIFF 777 MB to 500 MB, lossy WebP 1,752 MB to 1,161 MB. TIFF's premultiplied copy for alpha pictures stays. The 512 MP case of A 513.7 MP TIFF that Lightroom Classic opens is refused with "image too large"; the 512 MP limit is slightly too low, and the message doesn't name it #1477 was not measured.How it was checked
Cancel:
a_dng_export_polls_the_cancel_between_its_stages(asserts at least the read's polls plus 4; no hook into the raw decoder to see them exactly) and two more, which fail with the polls removed. Logo: pinned output unchanged against the old per-call computation kept in the test module; the tests can't fail against the old code, so the cache key and the keep limits were checked by mutating them. Copies: existing export and codecs tests, clippy-D warnings,cargo xtask notes --checkandcargo xtask paritypass.cargo xtask ci --quick --base origin/stagingon this branch (macOS, stagingd4c89211fmerged): fmt, brand, quarantine, docs, notes, i18n, windows, clippy, heif and stamp pass. Tests of lcc-codecs and lcc-engine: all pass exceptdevice_sync::tests::a_shared_collection_brings_photos_files_and_edits_both_ways(environmental on that machine) and two that failed once in a loaded run and pass alone:io_sched::tests_copies::a_copys_bytes_set_its_destinations_stall_timeandtests_color::one_field_wb_preset_gives_the_same_result_in_command_preview_and_import. Parity, layers, assets, wasm and deny: pass.This branch and the five earlier PRs of Export: a failed sidecar under Overwrite, long metadata in a JPEG, preview and cancel, one rule for names, depth and profile in one place #1838 were also merged together with Export: the preview's sharpening and watermark follow its size, and the originals guard no longer costs the window a third of a second #1847 and gated as one on the M1 (fmt, brand, quarantine, docs, notes, i18n, windows, clippy, heif, stamp, parity, layers, assets, wasm and deny pass; the tests fail only where plain
stagingfails). Thenstagingand Export: the preview's sharpening and watermark follow its size, and the originals guard no longer costs the window a third of a second #1847's branch were merged in (the 9 conflict hunks inexport.rsresolved keeping both sides): fmt, brand and notes checks, clippy-D warningson lcc-engine, lcc-codecs and lcc-ui-egui, and the engine export (276), originals (40), run-presets (10) and memory (22) tests, lcc-codecs (130 + 83) and the UI export tests (69) pass.🤖 Generated with Claude Code