Skip to content

feat: add WebP (RIFF/WEBP) image EXIF support#61

Open
mindeng wants to merge 11 commits into
mainfrom
feat/webp-support
Open

feat: add WebP (RIFF/WEBP) image EXIF support#61
mindeng wants to merge 11 commits into
mainfrom
feat/webp-support

Conversation

@mindeng

@mindeng mindeng commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Adds WebP image support to nom-exif: detects RIFF/WEBP files and extracts EXIF/GPS from the EXIF chunk via the unified parse_exif / read_exif (sync + async) APIs. Scope is EXIF-only (no XMP).

  • MIME detection (src/file.rs): new MediaMimeImage::Webp + check_webp ("RIFF"…"WEBP"), wired into the detection chain.
  • Pure RIFF chunk walker (src/webp.rs): webp::extract_exif(state, buf) walks the chunk stream, skipping large image-bitstream chunks via ClearAndSkip, returning the EXIF payload (raw TIFF). Bounds the walk by the RIFF size field (WebP has no terminator chunk) and threads the remaining-bytes bound across skips via ParsingState::WebpPastHeader(usize). Strips a stray Exif\0\0 marker if an encoder wrote one.
  • Generic dispatch integration (src/exif.rs): rides the existing extract_exif_with_mime path — reuses the sync and async drivers with zero async-specific code. New MalformedKind::WebpChunk.
  • Streaming EOF tolerance (src/parser.rs): small-file tolerance widened from Png to Png | Webp.

Design notes

WebP EXIF sits after the image bitstream, so the walker must skip potentially-large VP8 /VP8L/ANMF chunks to reach it — handled by ClearAndSkip with the RIFF-size bound carried across the skip. A no-EXIF WebP terminates cleanly with Error::ExifNotFound rather than reading to EOF.

Full design + implementation plan under docs/superpowers/.

Test Plan

  • cargo test — 427 passed, 0 failed (default features)
  • cargo test --features tokio — 432 passed, 0 failed
  • cargo fmt --check clean; cargo clippy --all-targets --all-features no issues
  • 18 WebP-specific tests: 12 walker unit tests (Need/ClearAndSkip resume, prefix strip, odd-size padding, RIFF-bound, overflow, bad/truncated header), 2 MIME-detection tests (incl. RIFF/WAVE negative), 4 end-to-end (memory sync, streaming sub-buffer, no-EXIF → ExifNotFound, async)

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.15152% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.69%. Comparing base (d0b1412) to head (4012cf9).

Files with missing lines Patch % Lines
src/webp.rs 94.28% 12 Missing ⚠️
src/parser.rs 96.66% 3 Missing ⚠️
src/error.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   90.52%   90.69%   +0.16%     
==========================================
  Files          38       39       +1     
  Lines        8593     8921     +328     
==========================================
+ Hits         7779     8091     +312     
- Misses        814      830      +16     
Flag Coverage Δ
nom-exif 90.69% <95.15%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mindeng mindeng mentioned this pull request Jul 7, 2026
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