From 994c820becbc2006b89aa52c86310449e352bcee Mon Sep 17 00:00:00 2001 From: Vikram Bhaskaran Date: Tue, 13 Oct 2026 01:23:57 +1100 Subject: [PATCH] Include HEIC, HEIF, and NRW when a folder is imported. --- crates/mcp/src/headless.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/mcp/src/headless.rs b/crates/mcp/src/headless.rs index 8678b1f7e..10a512faa 100644 --- a/crates/mcp/src/headless.rs +++ b/crates/mcp/src/headless.rs @@ -13,7 +13,7 @@ use crate::backend::{Backend, ProgressHook}; /// File extensions recognised as photos when expanding folders. pub const PHOTO_EXTENSIONS: &[&str] = &[ "jpg", "jpeg", "png", "tif", "tiff", "webp", "dng", "cr2", "cr3", "nef", "arw", "raf", "orf", "rw2", "rwl", "raw", "pef", "srw", "psd", "jxl", - "gif", "bmp", "avif", // containers LightCraft cannot decode but imports as preview only (their embedded JPEG) + "gif", "bmp", "avif", "heic", "heif", "nrw", // avif is preview-only; heic/heif/nrw match the engine list (#1080) "iiq", "crw", "mrw", "x3f", "kdc", "mos", "erf", "3fr", "fff", ]; @@ -193,6 +193,29 @@ pub fn expand_paths(paths: &[String]) -> Vec { out } +#[cfg(test)] +mod expand_tests { + use super::expand_paths; + + #[test] + fn a_folder_import_includes_heic_heif_and_nrw() { + let dir = std::env::temp_dir().join(format!("lightcraft-ext-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + for name in ["a.heic", "b.HEIF", "c.nrw", "d.png", "note.txt"] { + std::fs::write(dir.join(name), b"x").unwrap(); + } + let got = expand_paths(&[dir.to_string_lossy().to_string()]); + let names: Vec = got.iter().map(|p| std::path::Path::new(p).file_name().unwrap().to_string_lossy().to_lowercase()).collect(); + assert!(names.contains(&"a.heic".into()), "{names:?}"); + assert!(names.contains(&"b.heif".into()), "{names:?}"); + assert!(names.contains(&"c.nrw".into()), "{names:?}"); + assert!(names.contains(&"d.png".into()), "{names:?}"); + assert!(!names.iter().any(|n| n == "note.txt"), "{names:?}"); + let _ = std::fs::remove_dir_all(&dir); + } +} + /// Encode by extension: `.png` (default), `.jpg`/`.jpeg` (quality), `.tif`/`.tiff`, `.webp` (lossless), /// `.avif`, `.jxl` — via the shared export encoder (embeds an sRGB profile). pub fn encode_image(ext: &str, img: &Rgba8, quality: u8) -> Result, String> {