Skip to content

feat(editor): warn when editing the embedded JPEG preview - #1966

Open
WilliamGiorno wants to merge 1 commit into
CyberTimon:mainfrom
WilliamGiorno:fix/embedded-preview-warning
Open

WilliamGiorno wants to merge 1 commit into
CyberTimon:mainfrom
WilliamGiorno:fix/embedded-preview-warning

Conversation

@WilliamGiorno

@WilliamGiorno WilliamGiorno commented Oct 19, 2026 •

Copy link
Copy Markdown

Description

When RAW decoding fails (decoder error or panic), RapidRAW silently falls back to the embedded JPEG preview and lets the user edit and export it, so users believe they are working on the RAW data. This PR surfaces that fallback in the editor.

Closes #1873

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Performance improvement
  • Code refactoring
  • Documentation update
  • UI/UX improvement
  • Build/CI or Dependency update

Changes Made

  • image_loader.rs: the base loader now also reports whether the embedded preview fallback was used. The flag is set only at the two fallback points (decoder error and decoder panic); load_base_image_from_bytes keeps its signature for all other callers (export, HDR, panorama, …).
  • load_image returns a new used_embedded_preview field; the flag is stored in DecodedImageCache so it survives cache hits.
  • The editor toolbar shows a non-blocking warning badge ("Embedded JPEG", tooltip: "Editing the embedded JPEG preview: RAW decoding failed") next to the file name while that image is open. It disappears when switching to another image.
  • Added the two strings to all 15 locales (non-English translations are machine-made, happy to adjust).

Screenshots/Videos

With a RAW the decoder rejects, the toolbar shows the yellow "Embedded JPEG" badge next to the file name; hovering it shows the tooltip "Editing the embedded JPEG preview: RAW decoding failed". With the same file intact, no badge is shown.

Testing

  • These changes were tested locally by a human and confirmed to work.
  • I haven't added any automated tests to the code because the codebase currently lacks a test suite.

Tested by hand with npm start on a Panasonic RW2 truncated after its embedded JPEG (header and preview intact, sensor data cut), so the decoder fails and the fallback kicks in:

  • truncated file: the "Embedded JPEG" badge appears, the image opens at the preview size (1920 × 1440) and the tooltip shows the full message;
  • original file: opens as a normal RAW, no badge.

cargo fmt --check passes; tsc, eslint, prettier --check and the i18n checks report no new issues compared to main. cargo clippy --all-targets --all-features -- -D warnings passes locally with the pinned 1.98 toolchain.

Test Configuration:

  • OS: Ubuntu 26.04.1 LTS (Wayland)
  • Hardware: Intel Core i3-10110U, Intel UHD Graphics (Comet Lake)

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

Reproduce with any RAW the decoder rejects (e.g. a Nikon Z6 III NEF with HighEfficiency* compression, or a RAW file truncated after its embedded preview): the log shows "Using embedded preview fallback" and the badge appears in the editor toolbar.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is created by an AI agent
  • This PR is mostly AI-generated but edited/merged together by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

When RAW decoding fails, the loader falls back to the embedded JPEG
preview without telling the user. load_image now reports
used_embedded_preview (kept in the decoded image cache) and the editor
toolbar shows a warning badge for that image.

Closes CyberTimon#1873

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@WilliamGiorno
WilliamGiorno marked this pull request as ready for review October 20, 2026 08:38
@lalibertemarc

Copy link
Copy Markdown
Contributor

also closes #1947

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: RAW decoding failure falls back to embedded JPEG without a clear indication in the editor

2 participants