YCbCr encoded TIFF file fails with with "color type `Unknown(24)` error"
I downloaded this test file: https://sampletestfile.com/wp-content/uploads/2023/08/13.5-MB.tif
Attempted to open it with:
use std::io::{Error, ErrorKind};
let image = ImageReader::open(&file_path)?.decode().map_err(|e| {
tracing::error!("Unable to decode {:?}: {}", &file_path, e);
Error::from(ErrorKind::Other)
})?;
Expected
Image decoded successfully.
Actual behaviour
I get the error:
Unable to decode "./13.5-MB.tif": The encoder or decoder for Tiff does not support the color type `Unknown(24)`
Reproduction steps
Download the image in the link I provided above, attempt to decode with image v0.25.6.
Attached is the ImageMagick identify -verbose print-out on the file.
Could you check if the issue happens with the latest commit on main? There's been a bunch of changes to TIFF decoding that we haven't released yet
Confirmed, I get the same error with:
image = { git = "https://github.com/image-rs/image.git", default-features = false, features = [
"bmp",
"ff",
"gif",
"ico",
"jpeg",
"exr",
"png",
"pnm",
"qoi",
"rayon",
"tga",
"tiff",
"webp",
] }
Looked in more detail. The problem is that the file uses YCbCr encoding. The underlying tiff crate can extract the pixel data, but we lack support for converting it to RGB:
https://github.com/image-rs/image/blob/d6490d8cbada50085ddbd41105a22c6c7b675874/src/codecs/tiff.rs#L88