The Wayback Machine - https://web.archive.org/web/20200903013331/https://github.com/SFTtech/openage/issues/1290
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

Set PNG compression optimization level via CLI #1290

Open
heinezen opened this issue Aug 23, 2020 · 8 comments
Open

Set PNG compression optimization level via CLI #1290

heinezen opened this issue Aug 23, 2020 · 8 comments

Comments

@heinezen
Copy link
Contributor

@heinezen heinezen commented Aug 23, 2020

Required skills: Python, maybe Cython

Difficulty: Easy

Our converter PNG export module supports 3 built-in compression levels

  • none
  • default libpng compression
  • optimized compression

However, this functionality is currently unused as the converter is hardcoded to always use the default compression setting. We should implement a way to set the desired compression level with a CLI flag. The CLI flag should be added to the main convert module creating the modpacks as well as the convert-file submodule that can convert standalone files.

@dev-patel2104
Copy link

@dev-patel2104 dev-patel2104 commented Aug 25, 2020

@heinezen can i work on these one ?

@TheJJ TheJJ added the just do it label Aug 25, 2020
@TheJJ
Copy link
Member

@TheJJ TheJJ commented Aug 25, 2020

No need to ask for permission, just do it and submit a pull request :)

@heinezen
Copy link
Contributor Author

@heinezen heinezen commented Aug 26, 2020

@dev-patel2104 You can :)

The most relevant code snippets are here:

def save(numpy.ndarray[numpy.uint8_t, ndim=3, mode="c"] imagedata not None,

and here:

def save(self, targetdir, filename, compression_level=1):

@janisozaur
Copy link
Contributor

@janisozaur janisozaur commented Aug 26, 2020

I would recommend you migrate to webp. I tested this recently on a few projects and there is pretty much 20% of bytes saved over lossless, fully optimized PNGs across the board.

@heinezen
Copy link
Contributor Author

@heinezen heinezen commented Aug 26, 2020

@janisozaur Interesting. Do you have more info about the decoding speed and memory usage?

@janisozaur
Copy link
Contributor

@janisozaur janisozaur commented Aug 26, 2020

No, sorry. I haven't checked.

Decoding speed was not a concern for me and memory usage should be similar to PNG - after all it's only decoding into buffer that would be exactly the same whatever the original format was.

@janisozaur
Copy link
Contributor

@janisozaur janisozaur commented Aug 26, 2020

According to webp devs themselves, it's pretty much better across the board: https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study (see table 3 for decoding)

@heinezen
Copy link
Contributor Author

@heinezen heinezen commented Aug 26, 2020

@janisozaur If it has better decoding speed that's a big plus :) Even better would be a GPU implementation, but I do not see anything about that yet.

I might implement experimental support for it in the converter. Should not be too hard to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.