image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.99k stars 620 forks source link

Some TIFF images completely garbled in decoding #1745

Open Shnatsel opened 2 years ago

Shnatsel commented 2 years ago

This happens in image v0.24.2

Expected

ref

Actual behaviour

image

Reproduction steps

use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    use image::io::Reader as ImageReader;
    let input = std::env::args().nth(1).unwrap();
    let output = std::env::args().nth(2).unwrap();

    let img = ImageReader::open(input)?.decode()?;
    img.save(output)?;
    Ok(())
}

invoked with image-convert in.tiff out.png

Images to reproduce this: tiff-mismatches-flowers.tar.gz

fintelia commented 2 years ago

This seems to be caused by image-tiff lacking support for planar images, but not reporting an error when seeing one. However, I'm not sure how worthwhile actually adding support would be given that the TIFF spec says this about planar images:

PlanarConfiguration=2 is not currently in widespread use and it is not recommended for general interchange. It is used as an extension and Baseline TIFF readers are not required to support it.