Skip to content

Commit

Permalink
feat: Remove writing of native camera RAW formats from SDK (#814)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
cdmurph32 authored Jan 8, 2025
1 parent 6320115 commit 8767514
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
16 changes: 15 additions & 1 deletion sdk/src/asset_handlers/tiff_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1414,7 +1424,11 @@ impl AssetIO for TiffIO {
}

fn get_writer(&self, asset_type: &str) -> Option<Box<dyn CAIWriter>> {
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> {
Expand Down
22 changes: 22 additions & 0 deletions sdk/src/jumbf_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8767514

Please sign in to comment.