shssoichiro / oxipng

Multithreaded PNG optimizer written in Rust
MIT License
2.95k stars 125 forks source link

Threshold option to use with pre-commit #627

Closed oscargus closed 5 months ago

oscargus commented 5 months ago

I use oxipng to keep down the size of test images which works great!

However, I noted that sometimes, probably due to improvements in newer version, a few bytes are saved and the pre-commit fails when running on multiple files. If this change is committed we will waste storage, not save it... It would be great with a switch where one can select to not write back an optimized version if the saving is below a certain threshold, probably in percent.

andrews05 commented 5 months ago

Hi @oscargus, this sounds like the same thing as #286 so I'll close this as a duplicate.

To comment on the idea: I can understand the use-case here, though it seems like a very niche/purpose-specific feature. Not to say this won't ever be implemented in oxipng, but you're probably better off making a wrapper-script to do this for you.

oscargus commented 5 months ago

Thanks! I agree that it is a niche use case for oxipng as such, but for pre-commit use, it would, sometimes, be awesome.

Sorry for not finding the duplicate. Pretty sure I searched for "threshold", so not sure how I missed it...