From bc7fc1f0ac89e139b43352db3db0689ee21f1d87 Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Fri, 1 Nov 2024 15:23:52 -0700 Subject: [PATCH] Support latest `image-tiff`, add fax4 test --- src/codecs/tiff.rs | 12 +++++++++++- tests/images/tiff/testsuite/fax4.tiff | Bin 0 -> 3003 bytes .../output/tiff/testsuite/fax4.tiff.aba6a268.png | Bin 0 -> 5914 bytes 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/images/tiff/testsuite/fax4.tiff create mode 100644 tests/output/tiff/testsuite/fax4.tiff.aba6a268.png diff --git a/src/codecs/tiff.rs b/src/codecs/tiff.rs index 9a46a79456..348f211243 100644 --- a/src/codecs/tiff.rs +++ b/src/codecs/tiff.rs @@ -39,7 +39,12 @@ where { /// Create a new `TiffDecoder`. pub fn new(r: R) -> Result, ImageError> { - let mut inner = tiff::decoder::Decoder::new(r).map_err(ImageError::from_tiff_decode)?; + let options = tiff::decoder::DecoderOptions { + expand_samples_to_bytes: true, + }; + + let mut inner = tiff::decoder::Decoder::new_with_options(r, options) + .map_err(ImageError::from_tiff_decode)?; let dimensions = inner.dimensions().map_err(ImageError::from_tiff_decode)?; let tiff_color_type = inner.colortype().map_err(ImageError::from_tiff_decode)?; @@ -54,6 +59,7 @@ where }; let color_type = match tiff_color_type { + tiff::ColorType::Gray(1) => ColorType::L8, // see `with_expand_samples_to_bytes` above tiff::ColorType::Gray(8) => ColorType::L8, tiff::ColorType::Gray(16) => ColorType::L16, tiff::ColorType::GrayA(8) => ColorType::La8, @@ -73,6 +79,10 @@ where tiff::ColorType::RGBA(n) | tiff::ColorType::CMYK(n) => { return Err(err_unknown_color_type(n.saturating_mul(4))) } + tiff::ColorType::Multiband { + bit_depth, + num_samples: _, + } => return Err(err_unknown_color_type(bit_depth)), }; let original_color_type = match tiff_color_type { diff --git a/tests/images/tiff/testsuite/fax4.tiff b/tests/images/tiff/testsuite/fax4.tiff new file mode 100644 index 0000000000000000000000000000000000000000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