Skip to content

Possible regression and possible fix #38

Description

@andrews05

This is in reference to oxipng/oxipng#579 where a regression was reported with zopfli v0.8.0 (in conjunction with Rust 1.74) when compressing some images.
I've found this can be resolved by adding a single line in lib.rs:

        Format::Zlib => {
            let mut zlib_encoder = ZlibEncoder::new_buffered(options, BlockType::Dynamic, out)?;
+           let mut in_data = std::io::BufReader::new(in_data);
            std::io::copy(&mut in_data, &mut zlib_encoder)?;
            zlib_encoder.into_inner()?.finish().map(|_| ())
        }

Why this changes anything I have no idea. It's possible it's not so much a regression as just noise but I haven't tested on many files to get an idea of the average case. So I'm not sure whether the above is actually an appropriate change to make.

For a faster test case than the one originally reported, try using issue-29.png in the oxipng test files.

The "bad" output from oxipng 9:

$ oxipng --zopfli --pretend tests/files/issue-29.png 
Processing: tests/files/issue-29.png
214347 bytes (5.52% smaller): Running in pretend mode, no output

The "good" output from oxipng 8 or with the above change applied:

$ oxipng --zopfli --pretend tests/files/issue-29.png 
Processing: tests/files/issue-29.png
214229 bytes (5.57% smaller): Running in pretend mode, no output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions