Skip to content

Fix TIFF detection for camera-authored files (#281) - #480

Merged
echelon merged 2 commits into
storytold:mainfrom
peiyan0:fix-tiff-browser-probe
Oct 10, 2026
Merged

echelon merged 2 commits into
storytold:mainfrom
peiyan0:fix-tiff-browser-probe

Conversation

@peiyan0

@peiyan0 peiyan0 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Closes #281

Problem

When browsing folders that contain TIFF files preserving camera EXIF tags (e.g. Make: SONY, Make: NIKON CORPORATION, Make: PENTAX, Make: RICOH, Make: SAMSUNG), lightcraft_raw::probe() previously checked only make.starts_with(...) without verifying that the file actually contained raw mosaic / CFA structures.
As a result:

  • lightcraft_raw::probe() misclassified ordinary TIFF files as camera RAWs (ARW, NEF, NRW, PEF, SRW).
  • probe_info or decode failed because ordinary TIFFs do not contain CFA mosaic data.
  • The files carried no embedded RAW preview, causing probe_bytes to fail with "unsupported raw without an embedded preview".
  • The import/browse scanner marked them as errors and filtered them out, so the photos never appeared in the browser grid.

Solution

  1. In crates/raw/src/lib.rs:
    • Require has_cfa in probe() for vendor raws (Nikon, Sony, Pentax/Ricoh, Samsung).
    • In has_raw_ifd(), include Pentax compression 65535, Sony tone curve (0x7010), and CFA pattern tags (0x828e, 0x828d).
  2. In crates/engine/src/files.rs:
    • If a raw file fails probe_info or decode and has no embedded preview, allow it to fall through to standard image decoders if lightcraft_codecs can decode it (as is the case with ordinary TIFFs).
  3. Added regression tests in crates/raw and crates/engine verifying that TIFFs with camera Make tags are recognized and loaded as ordinary images rather than raw files.

@echelon

echelon commented Oct 9, 2026

Copy link
Copy Markdown
Member

Thank you @peiyan0! Requiring raw evidence before treating a Sony/Nikon/Pentax/Samsung TIFF as a raw is the right idea. It needs a few changes before it can land:

  1. Conflict with main. Main now has a Samsung-with-Pentax-maker-note → PEF rule, and its test samsung_make_with_a_pentax_maker_note_is_pef (a non-CFA RGB fixture) contradicts your test that a non-CFA "SAMSUNG" TIFF is not a raw. Please merge main and decide: either require raw evidence there too (and give that fixture a CFA photometric), or keep the maker-note rule ahead of the CFA check.
  2. Count Exif CFAPattern (0xA302) as raw evidence for PEF. Main's PEF reader now takes its layout from it, and uncompressed/PackBits PEFs whose IFD lacks a CFA photometric tag would otherwise be demoted to TIFF.
  3. Drop or narrow the crates/engine/src/files.rs fallback. It re-indents about 150 lines, and it turns a corrupt raw with no embedded preview into an "image" of its tiny IFD0 thumbnail (e.g. 160×120) instead of an import error. Your engine regression test passes with only the probe change.
  4. If you can, check against real ARW/NEF/NRW/PEF/SRW samples (cargo xtask corpus --download).

If you haven't already, please join our Discord: https://discord.gg/artcraft

…Samsung/Pentax rules (storytold#281)

Merge origin/main into storytold#480 and apply the review:
- the Samsung-with-a-Pentax-maker-note -> PEF rule now also needs raw evidence; its test fixture
  gets a CFA photometric, and the same RGB file without it is not a raw;
- for the Pentax family the Exif CFAPattern (0xa302) counts as raw evidence, as main's PEF reader
  takes its layout from it (uncompressed / PackBits PEFs);
- Samsung's private raw compressions 32769..=32773 count for SRW (NX1 / NX500 use 32773);
- the engine fallback in files.rs is dropped (main's version kept): a corrupt raw without a
  preview stays an import error; the engine regression test for camera-authored TIFFs is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Thank you @peiyan0! This landed in #692. Following the review, I made these changes on your branch:

  • Samsung with a Pentax maker note now also needs raw evidence.
  • Exif CFAPattern counts as evidence for Pentax, Ricoh and Samsung.
  • SRW compressions 32769–32773 count for Samsung, so NX1/NX500 files stay raws.
  • Main's files.rs was kept.
    It passed on the full CC0 corpus.

Please join our Discord if you haven't already: https://discord.gg/artcraft

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.

[BUG][MacOS] LightCraft doesn't display tif files

2 participants