image icon indicating copy to clipboard operation
image copied to clipboard

YCbCr encoded TIFF file fails with with "color type `Unknown(24)` error"

Open ronjakoi opened this issue 5 months ago • 3 comments

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.

identify.txt

ronjakoi avatar Jul 16 '25 21:07 ronjakoi

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

fintelia avatar Jul 16 '25 23:07 fintelia

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",
] }

ronjakoi avatar Jul 17 '25 06:07 ronjakoi

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

fintelia avatar Jul 18 '25 01:07 fintelia