Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable brute Zopfli iterations #660

Open
ace-dent opened this issue Dec 3, 2024 · 6 comments
Open

Enable brute Zopfli iterations #660

ace-dent opened this issue Dec 3, 2024 · 6 comments

Comments

@ace-dent
Copy link

ace-dent commented Dec 3, 2024

Newer versions of Zopfli can also operate in a "do iterations until no compression gains are achieved" mode, which can be useful for people looking into brute-forcing their way to marginally better compression, and that is more straightforward to expose in OxiPNG through additional dedicated command-line switches than by overloading already existing ones.

Originally posted by @AlexTMjugador in #640 (comment)

@andrews05
Copy link
Collaborator

Unfortunately this is similarly deferred until the next major release as it would also be a breaking change to the API. I'm tempted to start a v10 branch though so you can at least play around with some builds...

@AlexTMjugador
Copy link
Collaborator

Yes, I think this and #658 should be implemented for the next major release, which I don't know when will it be.

@dustdfg
Copy link

dustdfg commented Dec 4, 2024

I didn't try it on different images. Maybe it will work well on photos but on a "cartoon" like images which consist primarily from solid areas 255 is enough

@ace-dent
Copy link
Author

ace-dent commented Dec 5, 2024

@andrews05 - neat; just wanted to keep it on the road map.
BTW, why would it be API breaking? I presumed a new parameter would be added, (e.g. --zz) that would override --zi. Or is you plan to overload the existing iterations function, where --zi 0 forces it to brute force? Cheers :-)

@dustdfg
Copy link

dustdfg commented Dec 5, 2024

@ace-dent It is talked here about allowing user to set values great than 255 up to 2^64. Currently parameter is u8 so it is bound to 255 if it is changed to u64, it brakes API/ABI. I am sure that you doesn't really need something bigger than 2^24. Brute force would mean all possible paths...

If you need good compression just use webp which is widely supported and if to believe to internet is faster. After using 255 you won't squeeze much (I guess so). Or use JPEG XL which compresses even better than webp but is almost unsupported by software and is slower...

@andrews05
Copy link
Collaborator

@ace-dent The issue is that the zopfli API option iterations_without_improvement is not currently exposed in the oxipng API.
When using the oxipng API you may do something like this:

    opts.deflate = Deflaters::Zopfli {
        iterations: NonZeroU8::new(15).unwrap(),
    };

But if we add iterations_without_improvement into the API, the above code will suddenly become invalid because it is incomplete.
So while adding new command line switches is not a breaking change, adding new options to the internal API is. The --zi switch was an easy add because the iterations option already existed in oxipng's API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants