image-rs / deflate-rs

An implementation of a DEFLATE encoder in rust
Apache License 2.0
53 stars 14 forks source link

v0.8.5 generates invalid PNGs #48

Closed lovasoa closed 4 years ago

lovasoa commented 4 years ago

I'm opening this issue because updating deflate from 0.8.4 to 0.8.5 in dezoomify-rs makes the tests fail. deflate is an indirect dependency of this project, used to generate and read PNG files.

The following image is a PNG created with png v0.16.6 and deflate v0.8.5 which cannot be opened with the same libraries :

err

The error returned is : CorruptFlateStream.

Running the same code (generating and reading the PNG) with png v0.16.6 and deflate v0.8.4 works without errors.

oyvindln commented 4 years ago

Hm, seems my fix for #47 may have broken something.

oyvindln commented 4 years ago

I've yanked 0.8.5 for now, can you check if 6c97e51 fixes the issue? I made changes that will hopefully fix this without re-introducing #47. I wasn't sure what the source for the you used as an example was here, but the commit did prevent the same issue happening when running dezoomify-rs on https://artsandculture.google.com/asset/light-in-the-dark/ZQFouDGMVmsI2w (using level 2, lower levels didn't trigger it) which was linked in the readme.

lovasoa commented 4 years ago

Thanks, I am going to test this. The example image I gave comes from the test suite; you can just run cargo test to reproduce the error.

lovasoa commented 4 years ago

The failing test is the one that runs dezoomify-rs --retries 0 'testdata/generic/map_{{X}}_{{Y}}.jpg' /tmp/out.png

lovasoa commented 4 years ago

I just ran the test, and 6c97e5143df139af578cdd884e0dee9940414ea1 indeed fixes the issue.

The test passes with:

[patch.crates-io]
deflate = {git="https://github.com/image-rs/deflate-rs",rev="6c97e5143df139af578cdd884e0dee9940414ea1"}

and it fails with :

[patch.crates-io]
deflate = {git="https://github.com/image-rs/deflate-rs",rev="fcbe4206c45cf55d80ae8feb94f0613fe795659f"}
oyvindln commented 4 years ago

Thanks.

lovasoa commented 4 years ago

Thank you for the quick fix