Repository navigation
Export: each format's bit depth, alpha and HDR behaviour come from one table, and the colour profile and metadata are put together in one place - #1843
Merged
emmertex merged 2 commits intoDec 2, 2026
Conversation
… from one table Seven functions and two inline matches each re-derived what a format does with bit depth, alpha and HDR. They agreed except in one place: Render to DNG with `hdr` on was written as a float HDR render (`effective_depth` = F32Hdr, which the format's own introduction says is intended: highlights above white are kept) while `hdr_output()` said it was not an HDR output, so the Export preview and the dialog's summary treated the file as SDR (the preview offered no HDR rendition and said the format was SDR). `effective_depth` also mapped requests `bit_depths` doesn't list (PNG 32, AVIF 16, JPEG XL 10) by rules held in separate match arms, and two encoders retyped `keeps_alpha` as `matches!(Png | Tiff [| Webp])`. Change: `ExportFormat::caps()` is the one table (offered depths, the sample format a request is written as, keeps alpha, how HDR is written, whether an HDR file is Rec. 2020). `effective_depth`, `bit_depths`, `hdr_output`, `gain_map`, `keeps_alpha`, the HDR arm of `effective_space` and the two inline matches read it. `effective_depth` is now "gain map: 8-bit; HDR output: float HDR; else the format's rule for the request", so it cannot disagree with `hdr_output` again. Render to DNG is marked as an HDR float format, so `hdr_output()` is true for it; the file written does not change. For the other ten formats every answer is identical to before (220 combinations compared against the old functions). The stored-`bitDepth` drop (`drop_unfit_depth`) already had one rule, `bit_depths`; its four call sites differ only in when the format is known, and are unchanged. Test: `every_format_answers_depth_hdr_alpha_and_space_from_one_table` pins every format x request (None, 0, 8, 10, 12, 16, 32, 255) x HDR off / single layer / gain map for depth written, HDR output, gain map and output space, plus offered depths, alpha, the rule "float HDR depth <=> HDR output without a gain map", and that Edit In offers the depths Export does. It fails with the old functions on the Render to DNG row. Manual: output/export-formats Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r in one place The embedded-metadata block (colour profile + Exif block + XMP packet -> `EncodeMeta`) was built four times in export (8-bit, gain map JPEG, AVIF/JPEG XL gain map, deep samples) and three more times in Edit In (float TIFF, 8/16-bit TIFF, PNG), each with its own copy of "which profile": the named profile of the output space in three, the render's linear matrix profile or the named one of `img.space` in the deep encoder, and the render's own profile or the named one in Edit In. Any rule on what goes into a file (a strip, a size rule) had to be repeated seven times, and the two JPEG file-size budgets each re-added the profile, Exif and XMP lengths by hand. Change: `export::Embedded` (`new` for parts already built, `of_metadata` for a `Metadata`, `encode_meta()` for the codecs, `len()` for a file-size limit) is the one place; the seven sites call it. No input gets a different profile: the same choice is made at each site, now passed as (space, the render's own profile if any). Before the refactor the output of all 900 combinations of nine formats, five spaces, with and without metadata, five depths/HDR settings and gain map on/off was hashed; after it, every hash is identical (a one-off check, not committed). Tests: `every_encode_path_embeds_the_profile_of_the_space_it_wrote_and_the_metadata_it_was_given` (pins, on the old code too, the profile, Exif and XMP of 8-bit JPEG/PNG/TIFF, 16-bit PNG/TIFF, float TIFF and gain map JPEG in five spaces, with and without metadata, and the JFIF density) and `embedded_parts_are_what_the_encoders_get_and_what_a_size_limit_counts`. They pass before and after the change by design (they pin it); the first fails when the float profile or the gain map's space is changed at the new call site. Manual: none, no user-visible change Co-Authored-By: Claude Sonnet 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.
Part of #1838 (entries 17 and 18).
In short: export decided a format's bit depth, alpha and HDR in half a dozen separate places, and they disagreed in one case that shows: for Render to DNG with HDR on, the file keeps highlights above white, but the Export preview said the format was SDR and the dialog summary left out "HDR". Now
ExportFormat::caps()is the one table and each place reads it. The colour profile, Exif block and XMP packet were also put together at seven separate sites (four in export, three in Edit In); one function does it now, with no change to what is embedded.Change
ExportFormat::caps()returns the depths a format offers, the depth used for a request (the documented "closest depth" fallback), whether it keeps alpha, and its HDR kind.effective_depth,bit_depths,hdr_output,gain_map,keeps_alpha, the HDR part ofeffective_spaceand two inlinematches!read it. The sites that drop a bit depth the format can't take already shared one function and are unchanged.hdr_output()is true for Render to DNG with HDR on (it was false whileeffective_depthsaid 32-bit float). The file written is unchanged; the Export preview and the dialog summary now treat it as HDR. Over about 1,000 answers (11 formats, 8 depth requests, 3 HDR settings, 4 outputs) compared old and new, that is the only one that changed.export::Embeddedputs together the profile andEncodeMetafor all seven sites. Nothing else changes: 900 encodes across 9 formats, 5 colour spaces, with and without metadata, 5 depth/HDR settings and gain map on and off were byte-identical before and after.How it was checked
every_format_answers_depth_hdr_alpha_and_space_from_one_tablegoes over every format, depth request and HDR setting, the depths offered, alpha, and "float HDR depth iff HDR output (minus gain map)", and that Edit In's depths equal export's; it fails on the old code at the Render to DNG row. A new test pins the embedded profile, Exif and XMP; it passes before and after on purpose, and catches two deliberate mutations. The export-preview UI tests still pass.Question: see the umbrella (entry 17): Render to DNG with HDR on, HDR or SDR-only?
cargo xtask ci --quick --base origin/stagingon this branch (macOS, stagingd4c89211fmerged): fmt, brand, quarantine, docs, notes, i18n, windows, clippy and stamp pass. Tests of lcc-engine: all pass exceptdevice_sync::tests::a_shared_collection_brings_photos_files_and_edits_both_ways(environmental on that machine) andrun_presets::tests::a_run_makes_previous_export_and_runs_the_plugin_hooks_and_destination("plug-in busy" on a loaded run; passes alone, and fails on the first run after a fresh build of plainstagingtoo). Parity, layers, assets, wasm and deny: pass.The five branches of this batch (this one and its neighbours) were also merged together on current
stagingand gated as one: fmt, brand, quarantine, docs, notes, i18n, windows, clippy, heif, stamp, parity, layers, assets, wasm and deny pass; the tests fail only where plainstagingfails too (device_sync,translated_catalogs_do_not_use_missing_menu_triangles,tests_phone_menus), plus one timing test inio_schedthat passes alone.🤖 Generated with Claude Code