jamsinclair / jSquash

Browser & Web Worker focussed image codec wasm bundles derived from the Squoosh App.
Apache License 2.0
250 stars 19 forks source link

Update OxiPNG source #24

Closed CodeF53 closed 1 year ago

CodeF53 commented 1 year ago

The last publish of @jsquash/oxipng was 11/18/2021, since then OxiPNG has undergone 3 major updates, including several optimization performance improvements.

Also please add alpha optimizations to OptimiseOptions

jamsinclair commented 1 year ago

Thanks for the suggestion @CodeF53. I can look into it but I'm not a codec expert so if it takes too long, I'll leave it as is. I'd welcome contributions from yourself or others if you'd like to update it.

As noted in the README, the codecs and code is almost identically copied from https://github.com/GoogleChromeLabs/squoosh, the only difference being we repackage them as web modules. The upstream repo has also not been updated in 2 years – https://github.com/GoogleChromeLabs/squoosh/tree/dev/codecs/oxipng. You could suggest upstream that they update it and then this repo can benefit from their updates.

jamsinclair commented 1 year ago

Also please add alpha optimizations to OptimiseOptions

@CodeF53 feel free to submit a PR and I'll happily accept it.

jamsinclair commented 1 year ago

I've created a draft of this upgrade in #30. It also includes the optimiseAlpha option (defaults to false).

In the interim I've published some pre-release versions. You can install them with

If you have time to spare @CodeF53 it would be great if you can help validate these upgrades work for you. Thanks! 🙇

CodeF53 commented 1 year ago

It works!

Dataset & Settings

PackXBR Nuxt Vanilla 1.20 items folder - xBRZ 4x - 14 threads

Data

Src - 208,896 bytes\ No Opt - 1,155,072 bytes\ Old - 3645ms - 626,688 bytes\ Next - 2981ms - 634,880 bytes\ New (alpha opt) - 2334ms - 577,536 bytes

Conclusions

Data to be taken with a grain of salt, as it varies a lot for small tests

Going to run a larger test to get better ideas in terms of how things average out in my use case

CodeF53 commented 1 year ago

Dataset & Settings

PackXBR Nuxt Faithful 32x - 1.19.4 - xBRZ 2x - 8 threads

Data

Src - 9,052,160 bytes\ No Opt - 39,489,536 bytes\ Old - 209296ms - 23,101,440 bytes\ New - 57092ms - 23,056,384 bytes\ New (alpha opt) - 55698ms - 21,737,472 bytes

Conclusions

Despite the clear margin of error (run with alpha optimizations being ~2000ms faster), its clear that the new release is atleast 3x faster for this type of dataset.

In terms of size:

jamsinclair commented 1 year ago

@CodeF53 thanks for the thorough testing, glad to see it seems to be working well 🤩

I'll look at publishing the official version from #30 and note the perf. improvements. Many thanks! 🙇

jamsinclair commented 1 year ago

I've published v2.0.0 that should contain the changes from #30.

If you still need a single thread only build, please install with npm i -S @jsquash/oxipng@next-single-thread-only. I plan to create a more general solution for all threaded modules in the near future (#33)

I'll mark this as resolved.