Skip to content

Decode Nikon Expeed 6 and 7 AFInfo2 geometry - #9547

Open
righthandabacus wants to merge 1 commit into
Exiv2:mainfrom
righthandabacus:feature/nikon-afinfo2
Open

righthandabacus wants to merge 1 commit into
Exiv2:mainfrom
righthandabacus:feature/nikon-afinfo2

Conversation

@righthandabacus

Copy link
Copy Markdown

Summary

Decode Nikon AFInfo2 versions 0300/0301 and 0400/0401/0402 using the field layouts documented in ExifTool's Nikon.pm.

 Nikon MakerNote tag 0x00b7
- 03xx/04xx: opaque Exif.Nikon3.AFInfo2 bytes
+ 0300/0301: Exif.NikonAf23 geometry and AF status
+ 0400/0401/0402: Exif.NikonAf24 geometry and AF status

Expose AF area X/Y, image width/height, area width/height, detection method, area mode, coordinate availability, and the layout-specific focus fields. Use the embedded MakerNote TIFF byte order and preserve uninterpreted bytes through the existing binary-array reader/writer.

Coordinates are meaningful when AFCoordinatesAvailable is 1. Stored numeric fields remain visible when it is 0, unlike ExifTool's conditional omission. Camera-dependent AF-point bitmap names and derived grid labels are outside this change.

Evidence

  • Before: test/data/NikonZ6.exv exposes AFInfo2 as a 60-byte undefined value.
    After: NikonAf23 reports image dimensions 6048 × 4024, AF center (4590, 2580), and area dimensions 285 × 308, matching ExifTool.
  • Debug build succeeds. All 329 fixture regression tests and 8 targeted tests pass:
    cd tests
    python3 runner.py bugfixes/github/test_nikon_afinfo2.py
    python3 runner.py bugfixes/github/test_issue_646.py
    python3 runner.py regression_tests/test_regression_allfiles.py
  • New tests cover seven AFInfo2 versions, both outer and embedded TIFF byte orders, coordinate availability, unknown versions, truncated blocks, and writes preserving unknown bytes. The existing D850 test verifies the 0101 layout.
  • ExifTool independently agrees on all six geometry fields across 14 generated version/byte-order fixtures. Real-image validation uses the two existing Nikon Z6 fixtures; 04xx coverage uses generated metadata.

Merge Danger

Door: Two-way; the decoder additions can be reverted.

Blast Radius: Nikon metadata.

The five newly recognized versions expose structured tags in place of the opaque AFInfo2 value. Older layouts retain their existing keys, unknown versions remain opaque, and new group IDs are appended to preserve existing enum values.

@neheb
neheb requested a review from kmilos October 30, 2026 20:36
@mergify

mergify Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

Add AFInfo2 layouts 0300/0301 and 0400/0401/0402, exposing AF area coordinates, dimensions, and status fields. Preserve uninterpreted bytes during metadata writes.

Validate all geometry fields against ExifTool, cover both TIFF byte orders and malformed versions, and update the two Nikon Z6 regression references. All 329 fixture regressions and 8 targeted tests pass.
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.

1 participant