jnsh / arc-theme

A flat theme with transparent elements (actively maintained fork)
GNU General Public License v3.0
902 stars 77 forks source link

Possible better png optimization with zopfli-png #109

Closed nick87720z closed 2 years ago

nick87720z commented 3 years ago

zopfli has dedicated png recompressor - zopflipng. When I tested both on some wallpaper, zopflipng reached nearly twice as good compression as optipng -o7, at default settings (after short look to help output it seems, zopflipng also supports lossy compression). Combining both was meaningless, as output size was same for both original and pre-optimized wallpaper versions. There are sizes from ls -1s --block-size=1:

  2682880 wp-optipng.png
  2461696 wp-optipng-zopflipng.png
  2973696 wp.png
  2461696 wp-zopflipng.png
jnsh commented 3 years ago

Thank you for the suggestion.

I was aware of zopfli, and other better alternatives to optipng, but since the benefit from png optimization is just a few kb of space savings for the whole theme, it hasn't been the top priority.

I'm in the process of switching the build system to meson, and with that, there won't be any kind of png optimization support initially, since implementing it turned out to be a bit tricky due to some meson limitations. I'll look at adding it again once the migration is complete.

jnsh commented 2 years ago

With https://github.com/jnsh/arc-theme/commit/3421f0ec49b4d16521a536ecf643039b764e4ddd, the PNG assets are pre-rendered and optimized with oxipng for future release tarballs.

I experimented with different PNG optimization options as well, and using zopfli made no difference compared to base oxipng -o max.

Implementing the PNG optimization when building from a git snapshot, where the assets aren't pre-rendered and optimized, is still fairly complicated and is not planned at this time. However I may look at implementing that some time in the future.

Since this issue is only about the zopfli PNG optimization, and I've determined that it's not beneficial with the Arc assets, I think this can be now closed.

eli-schwartz commented 2 years ago

Sadly, the Fs module too is missing FeatureNew decorators... it is only available since 0.53.0

I've discovered a few other modules similarly missing these, and added the lot of them in https://github.com/mesonbuild/meson/pull/9762

eli-schwartz commented 2 years ago

According to repology, there don't seem to be any interesting target distros that have 0.50 but not 0.53, and for example Ubuntu goes straight from 0.45 (in 18.04) to 0.53 (in 20.04). So this is a reasonable place to bump the minimum version. Ubuntu users at least won't notice the problem anyway, though.

jnsh commented 2 years ago

@eli-schwartz Thank you for pointing that out, and for the upstream Meson fixes.

I agree that bumping the version requirement to 0.53.0 is perfectly fine, so luckily this didn't cause much extra hassle.

I'll keep my eye open for any other meson features that may be missing the FeatureNew check as well.

eli-schwartz commented 2 years ago

Thanks, hopefully there won't be many though. ;) Our general goal is to be fairly complete.