Skip to content

fix: decode standard images saved with a RAW extension - #1851

Open
baseq wants to merge 1 commit into
CyberTimon:mainfrom
baseq:fix/raw-extension-with-jpeg-content
Open

baseq wants to merge 1 commit into
CyberTimon:mainfrom
baseq:fix/raw-extension-with-jpeg-content

Conversation

@baseq

@baseq baseq commented Oct 5, 2026

Copy link
Copy Markdown

Problem

Some photo exports, notably Google Photos downloads, save JPEGs under the original RAW filename (DSC03621.ARW, P1000123.RW2, ...). RapidRAW picks the decoder from the extension alone, so these files go to rawler, which fails because there is no TIFF/RAW container:

[WARN] Error developing RAW file 'E:\...\DSC03621.ARW': Error: No decoder found, model '', make: '', mode: ''

Opening such a folder fails for every image. In the case that prompted this PR, all 567 .ARW/.RW2 files in the folder were JPEGs (FF D8 FF E0 ... JFIF).

Fix

  • formats::has_non_raw_image_signature(bytes) checks the JPEG (FF D8 FF) and PNG magic bytes. None of the supported RAW containers start with either (TIFF-based II*\0/MM\0*, RW2 IIU\0, CR3 ISO-BMFF, RAF FUJIFILM, X3F FOVb, CRW CIFF, ...).
  • load_base_image_from_bytes uses this to skip the RAW pipeline (both Apple RAW 9 and rawler) and decode the file with the standard image decoder, which already detects the format from the content and applies EXIF orientation. An info line is logged when this happens.

is_raw_file stays extension-only. It has ~30 call sites, many of them in folder listing and some that run on paths without bytes, so content sniffing belongs at the point where the bytes are decoded.

Testing

  • New unit tests in formats.rs (JPEG/PNG detected, TIFF/RAF/empty input not).
  • Ran a temporary local test that loads one of the affected .ARW files through load_base_image_from_bytes: it now decodes (4894×3269) instead of erroring.
  • cargo fmt --check and cargo clippy --all-targets -- -D warnings pass on Windows. I couldn't run clippy with --all-features locally because there's no libgphoto2 on Windows.

🤖 Generated with Claude Code

Some exports (e.g. Google Photos downloads) save JPEGs under the original
.ARW/.RW2 filename. RapidRAW picked the decoder purely by extension, so
rawler failed with "No decoder found, model '', make: ''" and the images
could not be opened.

Check the file signature in load_base_image_from_bytes and fall back to the
standard image decoder when a RAW-named file is actually a JPEG or PNG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baseq
baseq requested a review from CyberTimon as a code owner October 5, 2026 14:23
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