Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support latest image-tiff, add fax4 test #2377

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/codecs/tiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ where
{
/// Create a new `TiffDecoder`.
pub fn new(r: R) -> Result<TiffDecoder<R>, 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)?;
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
Binary file added tests/images/tiff/testsuite/fax4.tiff
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading