Skip to content

Nikon: the D1X renders squashed to 3:1 (non-square pixels), the Coolpix E8800 decodes as two stacked fields, and P330/P7700/P7800 NRWs stay preview-only outside #671's layouts #1274

Open

Description

@AlexChambers

Summary

On main at 25ef65c, two Nikon NEF layouts decode but give wrong pixels (geometry), and a third stays preview-only without an open PR that covers it. I found all three in a compatibility sweep of the CC0 raw.pixls.us files for every maker except Sony, which covered all 91 Nikon bodies with CC0 files on the site.

1. D1X: pixels twice as tall as wide, rendered as if square

Value
File raw.pixls.us 1786 (12-bit uncompressed)
Sensor data 4028 x 1324, developed 4024 x 1324
Render at --size 1200 1200 x 395, aspect 3.04
Camera preview in the file 570 x 375, aspect 1.52 (the camera's own JPEGs are 3008 x 2000)
Against the preview luminance correlation 0.20, ΔE76 27.1. The look fit is rejected because the frames don't match.

The D1X photosites are rectangular, so its 1324 rows cover a 3:2 picture. LightCraft has no notion of a pixel aspect ratio. The DNG DefaultScale tag exists as a constant (crates/tiff/src/tags.rs:118) but nothing reads it, so DNGs with non-square pixels would be affected too. The compressed D1X NEF stays refused as Huffman-coded (see #671), so only uncompressed D1X files reach this.

Suggested fix (not cheap): give RawImage a pixel aspect, set to 2:1 vertical for the D1X and taken from DefaultScale for DNG. Then have the develop step resample after demosaicing, so the developed size becomes about 4024 x 2648. A per-model special case in the NEF decoder would also work, but it can't simply duplicate mosaic rows without breaking the CFA.

2. Coolpix E8800: the E8400's two-field layout, not covered by #672

Value
File raw.pixls.us 2769
Sensor data 3280 x 2454, 12-bit, the same size as the E8400
Render two squashed copies of the scene, one above the other: the top field brownish, the bottom one blue and noisy
Against the camera JPEG luminance correlation 0.21, ΔE76 32.0, fit rejected; no as-shot white balance read

#672 (open) decodes the E5700 (CYGM) and E8400 two-field NEFs. Its branch matches "only these two models, at exactly these sizes and 0x828e patterns", so the E8800 keeps the stacked-field decode. #1045 (open) records the E5700, E8400 and E8800 as unsupported in evidence.tsv.

Suggested fix (cheap, under 2 hours, on top of #672): measure the E8800's field order and CFA on the CC0 file with #672's hue-correlation check. If they match the E8400's, add the model to #672's list.

3. Coolpix P330, P7700 and P7800 NRW: 12-bit samples in 16-bit words under compression 34713, not in #671's groups

These three bodies' CC0 NRWs (912, 5495, 1425) open preview-only with "Nikon compressed NEF without a linearization table (maker note 0x96)". This is a preview-only fallback.

Suggested fix (cheap, under 2 hours, on top of #671): add a group for StripByteCounts == width × height × 2, read as 16-bit words in the file's byte order. Check the byte order and the value range (at most 4095) on the three CC0 files, and check the green against each camera JPEG as #671 does.

Reproduce

curl -sSLo d1x.nef 'https://raw.pixls.us/getfile.php/1786/nice/Nikon%20-%20D1X%20-%2012bit%2012bit%20uncompressed%20(3.0422960725076).NEF' && lightcraft-cli render d1x.nef -o d1x.jpg --size 1200
curl -sSLo e8800.nef 'https://raw.pixls.us/getfile.php/2769/nice/Nikon%20-%20Coolpix%20E8800%20-%2012bit%2012bit%20uncompressed%20(4:3).NEF' && lightcraft-cli render e8800.nef -o e8800.jpg --size 1200
  • D1X expected: about 3:2. Actual: 1200 x 395.
  • E8800 expected: one picture. Actual: two stacked half-height copies.

Related

Activity

  1. radialmonster commented on Oct 13, 2026

    @radialmonster
    Contributor

    The E8800 two-field decode (point 2) is now covered by #672, which detects the stacked-field layout from the image data. The same change also fixes the E5400, E5700 and E8400. The D1X aspect and the compressed P330/P7700/P7800 NRWs are not part of it.

  2. radialmonster commented on Oct 13, 2026

    @radialmonster
    Contributor

    The D1X aspect (point 1) is now covered by #1475. It reads the pixel aspect from the raw IFD's X/Y resolution and stretches the rows, so the uncompressed D1X sample now renders 3:2 (4024x2648). The compressed D1X sample and the compressed P330/P7700/P7800 NRWs are still preview-only.

  3. radialmonster commented on Oct 28, 2026

    @radialmonster
    Contributor

    The D1X aspect (point 1) is only partly fixed. #1475 reads the pixel shape from the raw SubIFD's X/Y resolution, which works when the camera writes 600 / 300. A D1X NEF on firmware Ver.1.01 (uncompressed, 4028x1324) writes 600 / 600 there instead, so the ratio check returns 1.0 and the picture still comes in squashed to about 3:1 on 0.14.0, 0.15.0 and main.

    So the resolution tags alone aren't enough for every D1X/D1H. When they say square, the frame shape (4028x1324 raw against the camera's 3:2 picture) still shows the pixels are 2:1, and that's what a complete fix should fall back to.

  4. radialmonster commented on Oct 28, 2026

    @radialmonster
    Contributor

    Details for anyone picking this up (line numbers on main 77c0a6a):

    • pixel_aspect_of() in crates/raw/src/vendor/nef.rs:185 takes the raw SubIFD's XResolution / YResolution and accepts 1.5 to 4. On the Ver.1.01 file both are 600, so it returns 1.0. Everything after it (stretched_height() in crates/raw/src/lib.rs:471, the row resample after demosaic, developed_size()) already works once the aspect is right.
    • That file's tags: IFD0 is a 160x120 thumbnail at 300/300, raw SubIFD 4028x1324 uncompressed at 600/600, PreviewIFD a 570x375 JPEG (3:2) at 72/72.
    • So the frame shape can be read from the file itself: raw width/height is 3.04, the embedded preview is 1.52, and the ratio rounds to 2. When the resolution tags give 1.0, falling back to round((raw w / raw h) / (preview w / preview h)), with the same 1.5 to 4 range, covers this file and leaves every square-pixel body at 1.0, because their raw and preview shapes match.
    • A test doesn't need a real file: a synthetic NEF with a 4028x1324 raw SubIFD at 600/600 and a 3:2 preview IFD should get pixel aspect 2 (fails on main), and the existing 600/300 case should still get 2.
  5. added 4 commits that reference this issue on Oct 31, 2026
  6. radialmonster commented on Nov 7, 2026

    @radialmonster
    Contributor

    Update: the compressed P330, P7700 and P7800 NRWs are no longer preview-only. They decode from the sensor data since v0.12.0 (#671), and v0.19.0 still does. Their strip turned out to be plain big-endian 16-bit words, exactly 2 x width x height bytes (be16_layout() in crates/raw/src/vendor/nef.rs, line 407 on main and v0.19.0).

    Still open here:

    • D1X on firmware Ver.1.01 (600 / 600 resolution tags): covered by open Contributors: add my entry (DAnaeto) #3497. A +1 there helps. (Its "Not in this PR" note still lists the NRWs as preview-only; only the compressed D1X is left.)
    • The compressed D1X NEF still opens preview-only, with "Nikon compressed NEF without a linearization table (maker note 0x96)". Its strip is entropy-coded (about 5.7 bits per sample), so no packed layout fits it. Not claiming, open for anyone.
  7. added a commit that references this issue on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions