Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Required skills: Python, maybe Cython
Difficulty: Medium
The openage converter is able to optimize the compression for created PNG files by utilizing a search algorithm inspired by OptiPNG. To do this, the search algorithm first tries 8 different compression settings by creating PNGs with these settings in-memory. The compression settings that produced the smallest PNG are then used to export the image data into a PNG file. Using the optimized compression usually results in a much smaller file size (~50% of unoptimized size). However, the optimized compression is currently much slower as the resulting PNG has to be created 8 times (instead of 1 time with unoptimized compression) before it can be exported.
The way we can speed this process up is to save the best compression settings for each source image in a configuration file and use them as input during the PNG export phase. As a result, the PNG exporter can skip the 8 trials of the search algorithm and directly generate the "best" PNG. Furthermore, using optimized compression would then be as fast as using unoptimized compression.
To do this, we have to do the following:
For the configuration file, TOML should be used. The compression settings should be accompanied by information to identify the source image file (i.e. filepath and a SHA-256 hash value).
Example:
Further Reading