Handle HEIC/HEIF media import (image crate cannot decode it) #90

Closed
opened 2026-07-20 19:44:03 +00:00 by hugo · 1 comment
Owner

Source: Audit section 3.

Context: crates/bds-core/src/engine/media.rs SUPPORTED_IMAGE_TYPES includes image/heic and image/heif (matching specs/media_processing.allium input_formats), but thumbnails/dimensions go through the image crate (util/thumbnail.rs image::open), which has no HEIC decoder — so a .heic import will be accepted as an image and then fail at dimension probe / thumbnail generation. bDS2 (Elixir, libvips-based) handles HEIC.

Task:

  1. First reproduce: import a .heic fixture and record the failure mode (import error? media row without thumbnails?).
  2. Fix by adding real HEIC decode support (research current Rust options on the web: libheif-rs bindings, or conversion at import) OR, if the maintainer prefers, drop heic/heif from SUPPORTED_IMAGE_TYPES and from specs/media_processing.allium input_formats (spec must match code either way; validate with allium).
  3. Whatever the choice, regenerate_missing_thumbnails must not loop forever on undecodable files.

Acceptance: .heic import either produces thumbnails+dimensions like bDS2, or is cleanly rejected per updated spec; test with a heic fixture.

**Source:** Audit section 3. **Context:** `crates/bds-core/src/engine/media.rs` SUPPORTED_IMAGE_TYPES includes image/heic and image/heif (matching `specs/media_processing.allium` input_formats), but thumbnails/dimensions go through the `image` crate (`util/thumbnail.rs` `image::open`), which has no HEIC decoder — so a .heic import will be accepted as an image and then fail at dimension probe / thumbnail generation. bDS2 (Elixir, libvips-based) handles HEIC. **Task:** 1. First reproduce: import a .heic fixture and record the failure mode (import error? media row without thumbnails?). 2. Fix by adding real HEIC decode support (research current Rust options on the web: libheif-rs bindings, or conversion at import) OR, if the maintainer prefers, drop heic/heif from SUPPORTED_IMAGE_TYPES and from `specs/media_processing.allium` input_formats (spec must match code either way; validate with `allium`). 3. Whatever the choice, `regenerate_missing_thumbnails` must not loop forever on undecodable files. **Acceptance:** .heic import either produces thumbnails+dimensions like bDS2, or is cleanly rejected per updated spec; test with a heic fixture.
hugo added the bug label 2026-07-20 19:44:03 +00:00
Author
Owner

Implemented in e9f2cdb. Added cross-platform pure-Rust HEIC/HEIF decoding with hpvcd, including orientation, clean-aperture display cropping, 8/10/12-bit conversion, alpha preservation, and a single shared decode for all thumbnail variants. Imports now store real HEIC/HEIF dimensions and generate the small/medium/large WebP plus AI JPEG artifacts. Added a real HEIC fixture and regression coverage for both extensions, display dimensions, and thumbnail outputs. Thumbnail repair now matches bDS2 by skipping SVG, continuing past undecodable images, and reporting processed/generated/failed counts through core, Lua, and CLI paths. Neutral review checked the issue, bDS2 thumbnails/file handling, and media/media_processing Allium rules. Verified with cargo machete, cargo clippy --workspace --all-targets -- -D warnings, cargo build --workspace, and cargo test --workspace (531 core tests passed, 1 explicitly ignored; all workspace tests passed).

Implemented in e9f2cdb. Added cross-platform pure-Rust HEIC/HEIF decoding with hpvcd, including orientation, clean-aperture display cropping, 8/10/12-bit conversion, alpha preservation, and a single shared decode for all thumbnail variants. Imports now store real HEIC/HEIF dimensions and generate the small/medium/large WebP plus AI JPEG artifacts. Added a real HEIC fixture and regression coverage for both extensions, display dimensions, and thumbnail outputs. Thumbnail repair now matches bDS2 by skipping SVG, continuing past undecodable images, and reporting processed/generated/failed counts through core, Lua, and CLI paths. Neutral review checked the issue, bDS2 thumbnails/file handling, and media/media_processing Allium rules. Verified with cargo machete, cargo clippy --workspace --all-targets -- -D warnings, cargo build --workspace, and cargo test --workspace (531 core tests passed, 1 explicitly ignored; all workspace tests passed).
hugo closed this issue 2026-07-22 16:50:08 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: hugo/RuDS#90