image icon indicating copy to clipboard operation
image copied to clipboard

Incorrect decoding of .ico file

Open Shnatsel opened this issue 3 years ago • 1 comments

This happens in image v0.24.2 from crates.io

Expected

GIMP renders the .ico file as it seems to be intended, with nice anti-aliasing. Here it is converted to PNG: orig

imagemagick also agrees with this rendering, ~~with very minor differences~~ bit-perfectly.

Actual behaviour

image-rs seems to remove the anti-aliasing and make the image a lot more jagged: image

Reproduction steps

The code I've used for decoding the .ico and converting it to PNG is:

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 like this: image-convert input.ico output.png

GIMP version 2.10.32

imagemagick version 6.9.10.23

Shnatsel avatar Jul 03 '22 22:07 Shnatsel

In fact, I have found a rather large amount of .ico mismatches; here are the 20 most significant ones: ico-mismatches.tar.gz

Shnatsel avatar Jul 03 '22 23:07 Shnatsel