-
Notifications
You must be signed in to change notification settings - Fork 125
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
Combine palette reduction and sorting #554
Conversation
This PR looks reasonable, but I guess it's a draft because it's a specific hotfix for the mentioned issue that may cause regressions or unwanted behavior changes in some edge cases? |
Yeah, I marked it as draft just because I want to consider my logic a little more. And indeed, it seems almost hacky for one specific image. |
I have a good number of images that show weird output size variations when OxiPNG is combined with Let me know if you'd like the images anyways, @andrews05 |
@Winterhuman You can try out development builds from the workflow runs if you like. Find them on the Actions page, e.g. https://github.com/shssoichiro/oxipng/actions/runs/6305282807 |
Just tried out that build with some test images. Unfortunately, the output size (just I'll make sure to open a separate issue with what I've found. EDIT: Now done |
@AlexTMjugador I've updated the logic here. It all comes down what we do when a palette reduction alters the image data (as opposed to just truncating the palette, for instance). In these cases, the logic goes like this:
It's similar to what I first posted but more correct in edge cases. |
Neat! I think your suggested changes are better, but I would hate to rush them into the v9 release and not think them through. For now, let's focus on releasing v9, which already has a lot of changes. A minor release can be pushed relatively quickly with this patch if we need to. |
Sounds good! Might help if we can get more reports of similar issues after release. |
Ran the newest force-push out of curiosity, and it's looking good! (left is the current push, right was the push I ran in #558)
Most of the results are a couple bytes of improvement, them staying the exact same, or a few bytes regressions for the non-Zopfli versions. The only notable result being this one which was one of the images included in #558 (though it's still an improvement over v8.0.0):
|
@Winterhuman The changes you're seeing will likely be due to the libdeflate update rather than anything in this PR. (Libdeflate is always used for evaluations, so can affect the outcome even when using Zopfli). |
@andrews05 @AlexTMjugador - sorry to disagree... I think this fix should be in v9 release, as it corrects a 'regression' introduced with the new palette optim code. For User's not backing up their images, they may lose an optimal palette, that may be difficult / impossible to regenerate with future fixes... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, fair point @ace-dent. Some weeks have passed by since this PR was made, and looking at it again with fresh eyes I think its logic is sound now. I vote we merge it! (My main reason for not merging this for v9 was that it'd delay its release, but that's kind of a moot point now.)
This PR resolves the regression issue in #553.
When a palette reduction occurs, we no longer force it to be the baseline. Instead we combine it with the sorting step and only make it the baseline if sorting fails. This way we can retain the original image as the baseline in these situations without changing the number of evaluations (therefore performance remains unchanged).
The mystery of how #553's palette is weirdly optimised remains unsolved.