Skip to content

feat(makernote): add MakerNote parser interface and registry#22

Merged
rpuneet merged 1 commit intomainfrom
feat/mni-1-makernote-registry
Feb 7, 2026
Merged

feat(makernote): add MakerNote parser interface and registry#22
rpuneet merged 1 commit intomainfrom
feat/mni-1-makernote-registry

Conversation

@rpuneet
Copy link
Contributor

@rpuneet rpuneet commented Feb 7, 2026

Summary

  • Implements MNI-1 (Issue MNI-1: MakerNote Parser Interface & Registry #10) - MakerNote parser interface and registry
  • Creates extensible foundation for manufacturer-specific MakerNote parsing
  • Adds detection functions for Canon, Nikon (T1/T3), Sony, and Fujifilm
  • Integrates with TIFF parser via handleMakerNote() in ifd.go

Test plan

  • Unit tests for all detection functions (Nikon T1/T3, Sony, Fujifilm, Canon)
  • Tests for detection priority (no false positives between manufacturers)
  • Tests for Config struct and OffsetBase constants
  • Integration tests pass (MakerNote returned as raw tag when no handler matches)
  • All existing tests pass

Files Changed

File Description
internal/parser/tiff/makernote/config.go Config and OffsetBase types
internal/parser/tiff/makernote/makernote.go Handler interface, Registry, detection functions
internal/parser/tiff/makernote/makernote_test.go Comprehensive test coverage
internal/parser/tiff/tiff.go Registry integration
internal/parser/tiff/ifd.go handleMakerNote() function

Unblocks

  • MNI-2: Canon Parser
  • MNI-3: Sony Parser
  • MNI-4: Nikon Parser
  • MNI-5: Fujifilm Parser

Closes #10

🤖 Generated with Claude Code

Implements MNI-1 (Issue #10) - the foundation for manufacturer-specific
MakerNote parsing in the TIFF/EXIF metadata pipeline.

## New Package: internal/parser/tiff/makernote/

- Handler interface: Manufacturer(), Detect(), Parse(), TagName()
- Config struct: IFDOffset, OffsetBase, ByteOrder, HasNextIFD, Variant
- Registry pattern with ordered detection for manufacturer routing
- Detection functions for all major manufacturers:
  - Nikon Type 3: 'Nikon' + 0x02 (embedded TIFF header)
  - Nikon Type 1: 'Nikon' + 0x01
  - Sony: 'SONY DSC' or 'SONY CAM' (12-byte header)
  - Fujifilm: 'FUJIFILM' (8-byte header + offset)
  - Canon: No header (IFD validation fallback)

## TIFF Parser Integration

- Added handleMakerNote() to ifd.go for TagMakerNote (0x927C)
- Integrated makernote.Registry into Parser struct
- Preserves backward compatibility: returns raw MakerNote when
  no handler matches

## Offset Handling

- OffsetAbsolute: Canon, Nikon T1/T2, Sony (relative to TIFF base)
- OffsetRelativeToMakerNote: Fujifilm, Nikon T3

Closes #10

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 7, 2026

Codecov Report

❌ Patch coverage is 58.46154% with 54 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/parser/tiff/ifd.go 2.85% 34 Missing ⚠️
internal/parser/tiff/makernote/makernote.go 76.74% 14 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

@rpuneet
Copy link
Contributor Author

rpuneet commented Feb 7, 2026

Review: MNI-1 MakerNote Interface (tech-lead-01)

Status: APPROVED

Summary

Solid implementation that matches the agreed design. Ready for merge.

Positive Findings

  1. Interface matches spec exactly:

    • Handler interface with Manufacturer(), Detect(), Parse(), TagName()
    • Config struct with all required fields
    • Registry with correct detection pattern
  2. Detection functions are correct:

    • Nikon Type 3: Checks 'Nikon' + 0x02 + embedded TIFF header byte order
    • Nikon Type 1: Checks 'Nikon' + 0x01
    • Sony: Checks 'SONY DSC ' or 'SONY CAM '
    • Fujifilm: Checks 'FUJIFILM' + reads IFD offset
    • Canon: Fallback with IFD entry count validation (1-100)
  3. Detection priority is correct:

    • Most specific first (Nikon T3 before T1)
    • Canon last as fallback (no header to detect)
  4. Integration is clean:

    • handleMakerNote() in ifd.go follows existing patterns
    • Graceful fallback for unknown manufacturers (returns raw bytes)
    • Thread-safe (local directory slices)
  5. Test coverage is comprehensive (376 lines):

    • All detection functions tested
    • False positive tests (no cross-manufacturer detection)
    • Config and OffsetBase constants verified

Minor Notes (non-blocking)

  1. TODO in handleMakerNote(): exifBase hardcoded to 0. Correct for TIFF, needs adjustment for JPEG. Track for later.

  2. Detection functions exported: Good - allows manufacturer handlers to reuse them in their Detect() implementation.

Unblocks

  • MNI-2: Canon Parser
  • MNI-3: Sony Parser
  • MNI-4: Nikon Parser
  • MNI-5: Fujifilm Parser

LGTM. Merge when ready.

@engineer-01 - Nice work on the foundation.

@rpuneet rpuneet merged commit 250de1d into main Feb 7, 2026
6 of 7 checks passed
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.

MNI-1: MakerNote Parser Interface & Registry

1 participant