From 8767514d1990bbeeab224a645affee978cd2732c Mon Sep 17 00:00:00 2001 From: Colin D Murphy Date: Wed, 8 Jan 2025 11:53:35 -0500 Subject: [PATCH] feat: Remove writing of native camera RAW formats from SDK (#814) * feat: Remove writing of native camera RAW formats from SDK Writers of native formats cannot be easily tested and are beyond the scope of the SDK. * Add specific test for TIFF CAI writer handler. --- sdk/src/asset_handlers/tiff_io.rs | 16 +++++++++++++++- sdk/src/jumbf_io.rs | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/sdk/src/asset_handlers/tiff_io.rs b/sdk/src/asset_handlers/tiff_io.rs index f281fa9a6..2d9811e67 100644 --- a/sdk/src/asset_handlers/tiff_io.rs +++ b/sdk/src/asset_handlers/tiff_io.rs @@ -68,6 +68,16 @@ static SUPPORTED_TYPES: [&str; 10] = [ "image/x-nikon-nef", ]; +// Writing native formats is beyond the scope of the SDK. +static SUPPORTED_WRITER_TYPES: [&str; 6] = [ + "tif", + "tiff", + "image/tiff", + "dng", + "image/dng", + "image/x-adobe-dng", +]; + // The type of an IFD entry #[derive(Debug, PartialEq)] enum IFDEntryType { @@ -1414,7 +1424,11 @@ impl AssetIO for TiffIO { } fn get_writer(&self, asset_type: &str) -> Option> { - Some(Box::new(TiffIO::new(asset_type))) + if SUPPORTED_WRITER_TYPES.contains(&asset_type) { + Some(Box::new(TiffIO::new(asset_type))) + } else { + None + } } fn remote_ref_writer_ref(&self) -> Option<&dyn RemoteRefEmbed> { diff --git a/sdk/src/jumbf_io.rs b/sdk/src/jumbf_io.rs index baaf7f12f..25e7448b8 100644 --- a/sdk/src/jumbf_io.rs +++ b/sdk/src/jumbf_io.rs @@ -423,6 +423,28 @@ pub mod tests { } } + #[test] + fn test_get_writer_tiff() { + let h = TiffIO::new(""); + // Writing native formats is beyond the scope of the SDK. + // Only the following are supported. + let supported_tiff_types: [&str; 6] = [ + "tif", + "tiff", + "image/tiff", + "dng", + "image/dng", + "image/x-adobe-dng", + ]; + for tiff_type in h.supported_types() { + if supported_tiff_types.contains(tiff_type) { + assert!(get_caiwriter_handler(tiff_type).is_some()); + } else { + assert!(get_caiwriter_handler(tiff_type).is_none()); + } + } + } + #[test] fn test_get_supported_list() { let supported = get_supported_types();