image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.86k stars 597 forks source link

Format error decoding Png: Invalid PNG signature. When reading png with embedded color profile #2260

Closed francisdb closed 2 months ago

francisdb commented 2 months ago

Gimp

image

macOS file info

image

Expected

Reads file

Actual behaviour

Format error decoding Png: Invalid PNG signature.

Reproduction steps

let decoder = image::io::Reader::open(file_path)?.with_guessed_format()?;
let dimensions_from_file = match decoder.into_dimensions() {...}

g5kscratchedmorelight.png.zip

Looks like there's more applications that have problems opening this file. Eg Firefox.

ripytide commented 2 months ago

I can't open that image with sxiv:

sxiv: g5kscratchedmorelight.png: Error opening image
sxiv: no more files to display, aborting

The output of pngcheck is:

g5kscratchedmorelight.png  this is neither a PNG or JNG image nor a MNG stream
ERROR: g5kscratchedmorelight.png

And https://www.nayuki.io/page/png-file-chunk-inspector also shows some errors.

I'm fairly confident that that is a invalid png image and so there is no issue with this library and this issue should be closed.

francisdb commented 2 months ago

Thanks for checking. Closing and might report back if I see this again for other images.

nayuki commented 2 months ago

g5kscratchedmorelight.png.zip

Regarding that ".png" file, it starts with the characters "8BPS". It is a Photoshop (PSD) file. https://stackoverflow.com/questions/20518335/why-do-photoshop-files-start-with-8bps

francisdb commented 2 months ago

Thanks @nayuki I should have just run file 😳

> file g5kscratchedmorelight.png 
g5kscratchedmorelight.png: Adobe Photoshop Image, 512 x 512, RGBA, 4x 8-bit channels