Repository navigation
PIXEL-SHIFT: Photo Merge ▸ Pixel Shift for Nikon Z 8 pixel-shift series - #1293
Merged
Merged
Conversation
…aw DNG, read a merged DNG like the camera's raw Series detection (lcc-raw pixel_shift): read_header reads the Nikon maker note of a frame (shot count, the frame's number from two tags that must agree, the exposure counter, the sensor position) from the first 512 KB of the file, the whole file when the start does not hold the tags. detect checks that a set of headers is one complete series (same camera, lens, exposure, raw size and image area; the numbers 1..N once each; consecutive counters; capture times evenly spaced against the series' own median interval) and says why it is not. A date in a header is bounded before it is used. DNG writing: the writer can add an Exif IFD (capture time with sub-seconds and offset, exposure, focal length, lens) and a JPEG preview as a reduced-resolution sub-image. A merged file carries a provenance block in its XMP (merge_provenance, under https://github.com/emmertex/chromaforge/ns/pixelshift/1.0/): engine version, shot count, the frames with name, capture time and exposure counter, and where the stored frames sat on the sensor. Reading: a DNG with that block is read like the camera's raw. Its colour tags and baseline exposure stay in the file for other converters but are not used; the white-balance multipliers come from its as-shot neutral and it has no colour matrices, so the starting look is fitted to its preview as for a NEF or NEFX (format Nef, binned previews of three-sample data). The preview's colour space is read from the DNG PreviewColorSpace tag, for such files only. Every other DNG is read exactly as before; tests cover both directions. Sources: own design, from measurements on own Z 8 files; the DNG specification. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lcc-merge pixelshift: the camera moves the sensor by one pixel between the four frames of a set and by half a pixel between sets (16 shots = 4 sets). A fixed table by frame number says where each frame's samples land on a grid twice as fine as the sensor; each merged pixel takes its red from one sample, its blue from one and its green as the mean (rounded down) of two. Nothing is interpolated, demosaiced or registered. Merger places one frame at a time, so peak memory is the merged image plus one frame; write_dng stores the result as a three-sample LinearRaw DNG on the camera's own scale (black and white level unchanged) with frame 01's colour, lens data, metadata and preview, packed with lossless JPEG, deflate or uncompressed. Only the 16-shot series is accepted; other counts are refused until measured. Measured against the NEFX NX Studio writes from the same frames (chromatic-aberration correction off): red and green are bit-identical over the whole frame in both series measured; blue is identical at 91.9 % and 93.9 % of sites and differs only in every twelfth sensor row, where the stored values are less noisy (likely filled in by the camera). The tests cover the placement for the four CFA phases, a 1:1 image area and an odd active origin, and the DNG round trips for every packing. Sources: own design, from measurements on own Z 8 files; the DNG specification. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Photo.merge_sources (MergeSources, MergeSource) records the series a merged photo was made from: engine version, shot count, the reference frame, the scale, and per frame its number, the frame's photo when it is in the library, its file name, capture time and exposure counter. Op::SetMergeSources sets it (undoable, journalled). A photo that remembers its frames takes its colour start like the camera's NEF (Photo::colour_format feeds relative_wb and fitted_look), as the engine reads such a file. Catalog format version 19; older catalogs open and are upgraded. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e CLI command
Photo Merge gets a Pixel Shift kind. plan_merge checks the selection as one complete
series before any frame is decoded and gives the reason when it is not (a typed
PixelShiftRefusal, so a front end can word it in the person's language); a result file
that already exists is refused, never replaced, renamed or reused. The job decodes,
places and drops one frame at a time, writes the DNG next to frame 01 with its
metadata (the union of the frames' catalog keywords, frame 01's descriptive fields and
capture time with sub-seconds and offset; no rating, label or edits), frame 01's own
JPEG as its preview and the provenance block, and finish_merge imports it, stacks it on
its frames and remembers them in the catalog. The merge opens with default develop
settings, no Auto Settings (parse_dialog: the dialog's own options do not apply to it).
New commands: merge.pixelShift {ids?, autoSettings=false, stack=true, outputDir?}
(CLI: merge pixel-shift) and merge.deleteSources {id?}, which moves the merged photo's
frames other than frame 01 to Recently Deleted through photo.delete and counts frames
that are already gone. A merged DNG imported on its own finds its frames in the library
again from its XMP, by file name and capture time; a frame that is not there stays in
the list as not found.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…, Delete Merge Sources, visible refusals Photo ▸ Photo Merge gets Pixel Shift and Delete Merge Sources in the menu bar, the grid's context menu and the command palette (one definition each). A refusal or a failure to start a merge is said in a message on the window, in the person's language, instead of only on the status line; a failure while the merge runs and a cancel already were. Choosing HDR, Panorama, HDR Panorama or Focus Stack on exactly one complete pixel-shift series asks whether to merge it as Pixel Shift instead (Pixel Shift / Continue with … / Cancel); any other selection is not asked. Delete Merge Sources asks first when "Confirm before deleting" is on, is greyed out on other photos and when only frame 01 is left, and says how many frames went and how many were already gone. 24 new texts, translated into all 17 languages (the fork catalogs, sorted). Tests drive the menu commands and the dialog buttons on synthetic frames: each refusal, an existing result, the three answers of the question, a merge that fails while it runs, Delete Merge Sources (confirm on and off, partial sources, the greyed-out states) and the frames a merged file finds again on import. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
docs/pixel-shift.md (how a series is recognised, what the merge does, the DNG and its provenance block, known differences from NX Studio's merge, how to use it), docs/merge.md, the manual's Photo Merge page, a What's New entry, a changelog entry and the gaps row for long-tail raw formats. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AlphaZentaurii
marked this pull request as ready for review
November 19, 2026 09:27
Owner
|
Automated triage pass: CI is green, the PR carries release notes, manual pages, gap entry and localized strings, and a scan of the non-test additions found no 🤖 Generated with Claude Code |
This was referenced Nov 22, 2026
Merged
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.
(No
Fixes #/Part of #line: I searched all issues and PRs of emmertex/chromaforge for pixel shift, NEFX, Nikon,high-resolution and sensor shift, and found no issue for this. #1267, the NEFX decoder, is the merged PR this builds on.)
Problem
A Nikon pixel-shift shot is a series of 4 to 32 raw frames that only become one image when they are merged. This PR
handles the 16-shot series. The app can read the merged NEFX that NX Studio writes (#1267) but cannot make the merge
itself, so the whole series has to go through NX Studio first.
Change
What it does. Photo ▸ Photo Merge ▸ Pixel Shift (menu bar, right-click menu, command palette; command
merge.pixelShift, CLIchromaforge-cli merge pixel-shift) merges the selected frames of one series into a 16-bit LinearRaw DNGwritten next to frame 01, imports it, selects it and stacks it on its frames. The merge runs in the background with a
row in the activity stack and a cancel. The merged photo opens like a freshly imported raw: no edits, and its white
balance, camera profile, fitted colour look and tone curve go through the same colour route as the NEFX of the same
series. Photo ▸ Photo Merge ▸ Delete Merge Sources moves the frames other than frame 01 to Recently Deleted through
the normal delete (the Confirm before deleting setting applies).
Using it. Select all 16 frames and choose Pixel Shift. A selection that is not one complete series is refused, with
the reason, in a message on the window and before any frame is decoded: a frame missing or twice, a file that is not a
pixel-shift frame, another camera / exposure / image size, frames that were not shot one after the other, a shot count
that is not supported. A series whose
<frame 01>-PixelShift.dngalready exists is refused too (nothing is replaced,renamed or reused). Choosing HDR, Panorama, HDR Panorama or Focus Stack on exactly one complete series asks whether to
merge it as Pixel Shift instead (Pixel Shift / Continue with … / Cancel).
How the merge works.
frame's number in the series (two tags that must agree), an exposure counter and a sensor position (reported only).
A selection is one series when the camera, lens, exposure, raw size and image area agree, the numbers 1..N appear once
each, the counters follow each other and the capture times are evenly spaced relative to the series' own interval
(the camera's interval setting runs from none to many seconds). Only the first 512 KB of each file is read, the whole
file when the start does not hold the tags.
sets (16 shots = 4 sets). A fixed table by frame number says where each frame's samples land on a grid twice as fine
as the sensor. Each merged pixel takes its red from one sample, its blue from one, and its green as the mean (rounded
down) of two. Nothing is interpolated, demosaiced or registered, and the maker-note positions are not used to place
anything. Frames are decoded, placed and dropped one at a time, so peak memory is the merged image plus one frame.
(570 MB for an FX series; decode about a second). The DNG carries frame 01's make and model, colour tags, white
balance, exposure data, capture time (Exif and XMP, with sub-seconds and offset), lens data (Nikon distortion as
OpcodeList3), the union of the frames' catalog keywords and frame 01's descriptive metadata (rating, label and editsare not carried), frame 01's own JPEG as its preview, and a provenance block in its XMP (
https://github.com/emmertex/chromaforge/ns/pixelshift/1.0/:engine version, shot count, the frames with name, capture time and counter, and the stored frames' place on the sensor).
The catalog keeps the same list (
Photo.merge_sources, catalog format 19); a merged DNG imported on its own finds itsframes again from its XMP.
are ignored by the app (they stay in the file for other converters), the white-balance multipliers come from the
as-shot neutral, and the starting look is fitted to the embedded JPEG as for a NEF/NEFX. Every other DNG, and every other
file, is read exactly as before.
Not in this PR: motion handling, drift correction or sub-pixel registration; 4-, 8- and 32-shot series (refused
until measured); Vignetting Calibration for merged files (the stored sensor window is kept for it); restoring a deleted
frame into its stack (see below); other cameras.
Known differences and limits
values are less noisy than in other blue rows (likely filled in by the camera); about half of NX Studio's values there
differ from ours, mostly at noise level with isolated larger differences. We keep the stored samples. No pattern was
visible in our tests.
starts with it off). Kept on purpose.
unsteady tripod drifts by up to about 0.6 px over the 16 shots and shows it as softness and colour fringes at fine
detail; NX Studio's merge doesn't correct drift either.
photo from its stack, Restore only clears the deleted flag), not something of the merge; noted in
docs/pixel-shift.md.Sources: own design, from measurements on our own Z 8 files (16-shot FX 3:2 and 1:1 series) and the NEFX/DNG files NX
Studio and this app write from them; the DNG specification for the tags. No other raw decoder's or pixel-shift tool's
source was read.
How it was checked
Parity with NX Studio's merge (chromatic-aberration correction off), two series (FX 3:2 and 1:1):
Raw data: red and green are bit-identical over the whole frame in both series; blue is identical at 91.9 % and 93.9 % of
sites and differs only in the rows described above.
Rendered (
chromaforge-cli compare, identical settings, lens correction off on both, 1600 px; mean / median / p99 ΔE00, lightnessbias), merged DNG against the NEFX:
Speed: a 16-shot FX merge takes about 7 s with the files in the OS cache (peak about 2.7 GB); on a cold hard disk it took
about as long as NX Studio's merge (checked by hand).
Tests added (about 30): series detection and spacing, the placement for the four CFA phases and for an odd active origin,
the DNG round trips for every packing, the Exif/XMP capture time and keyword union, the catalog format and ops, the engine
planning and refusals, the merged-DNG colour route against a normal DNG and a NEF, and in the UI the refusals, the existing
result, the three answers of the question, Delete Merge Sources (with the confirm setting on and off, partial sources and
the greyed-out states) and the frames a merged file finds again on import. Seven of the eight UI tests and the menu-defaults engine
test failed against the old code (the eighth UI test, a failure while the merge runs, already worked there). The colour-route tests (raw, catalog, engine) need the new API to
compile, so they could not be run against the old code; they check both directions instead: a merged DNG is read like the
camera's raw, and a normal DNG and a NEF are read as before. A hostile date in a frame header gives no time instead of
overflowing.
cargo fmt --check, clippy on the touched crates,cargo xtasknotes / i18n / docs / brand / layers / assets passcargo test -pmeta, merge, catalog, raw, engine, ui-egui and cli run; the failures are pre-existing, belowcargo xtask ci --fast: all 14 steps pass (fmt, brand, quarantine, docs, notes, i18n, clippy, heif, parity, layers,assets, deny, wasm); the Android step was skipped on the machine it ran on because the Rust target is not installed
(CI runs it).
cargo xtask sil: 4 of 4 pass (the corpus raw step skips without the corpus). Both were run on the finalsix commits. Each commit was also built and its crate's tests run on its own (raw, merge, catalog, engine, ui-egui).
Failing tests, and the baseline. Run on this branch and on
upstream/main(8b22ec6):upstream/maintests_face_recognize::unnamed_faces_come_with_look_alikes_together…a_persons_page_shows_their_faces_and_back_returns_to_everyone,unnamed_faces_are_selected_and_named_together,the_groups_hold_each_persons_suggested_faces…,the_peoples_search_narrows_the_cards_by_name,rename_person_from_the_card_and_the_pageno_language_has_translation_gaps(the four face strings),ui_text_has_no_em_dashes(a What's New line),latin_and_cyrillic_languages_paint…cli_inspects_and_imports_large_sparse_lightroom_catalogthe_settings_in_the_dialog_are_saved,fast_edits_keep_at_most_two_renders…,component_rows_show_their_operation…,a_swipe_scrolls_the_grid…,an_edited_raw_never_rendered_shows_a_draft_of_its_edit_at_onceupstream/main(the fifth was not run alone there). Which of them fail varies between full runs on this branch (below)The tests in the last row are load-sensitive: they fail only in the full parallel run of the ui-egui suite (about 9 to 11
minutes) and pass when run on their own. Two full runs were made on this branch. In the first, the first four failed; in
the second (on the final six commits)
component_rows_show_their_operation…andan_edited_raw_never_rendered_shows_a_draft_of_its_edit_at_oncefailed and the other three passed. I did not run the fullsuite on
upstream/main, so that these tests are flaky there too is not proven; none of them touches Photo Merge.Everything else passes: meta 221, merge all, catalog 393, raw 772, engine 2477 of 2478, ui-egui 2147 to 2149 of 2159 (the two runs), cli 34 of 35 in
cli.rsand every other target.Screenshots
None: the screens show a photographer's raw files. The menu entries and dialogs are the existing ones.
Merging
crates/engine/src/merge.rs,crates/engine/src/tests_merge.rs,crates/catalog/src/model.rsand the manual'sdevelop/merge.md(a merge resultjoins the album it was started from); a trial merge shows small textual conflicts in the engine files and the manual page (the catalog model merges cleanly) and no overlap in behaviour (the
album step would apply to a pixel-shift result as to other merges). Whichever lands second takes the resolution. Release 26.47.2: changelog and version #1289 and
Release 26.47.2 CI: fix full-suite failures after the People categories #1290 (release 26.47.2) touch the fork catalogs but merge with this branch without conflict. Issue #1211: expose source decode provenance and draft status in pixel filter _image #1233 (pixel filters in
plug-ins) is unrelated.
would read with the new colour route (white balance on the relative scale); none was ever released.
VERSION19 (Photo.merge_sources,Op::SetMergeSources; older catalogs openand are upgraded). No process version,
RENDER_CACHE_VERSIONorLOOK_VERSIONchange.unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgatechanges: one dev-dependency,
lcc-tiff(a workspace crate) for the ui-egui tests; Delete Merge Sources deletes throughthe existing
photo.delete; nothing else.Checklist
from files: no
unwrap/expect/panic!outside tests; indexing is by positions the code made itself or aftera bounds check; three spots were hardened: a date in a frame header is bounded (year 1–9999, clock fields in
range) before the day arithmetic, the active-area and frame-size checks in the merge use saturating arithmetic, and
white-balance multipliers taken from a merged DNG's as-shot neutral must be finite. A test covers the hostile date.
tr()and has its key incrates/ui-egui/locales/fork/*.json(all 17 languages, sorted)docs/gaps.mdrow 20 updated.docs/parity-checklist.mdis not touched by this PR: its summary table is stale onmainalready (the table is computed from that document alone, which this PR does not change), socargo xtask parityprints the stale-summary note there too and was left alone to keep this PR to one changedocs/manual-site/.../develop/merge.md,docs/pixel-shift.md,docs/merge.md; What's New and changelog entries added