mm201 / pkmn-classic-framework

Pokémon application logic for Generation IV and V, including servers
http://pkmnclassic.net/
Other
219 stars 43 forks source link

PNG: lossless compression #124

Open SombrAbsol opened 11 months ago

SombrAbsol commented 11 months ago

I losslessly compressed all PNG images with compression algorithms. Website pages should load faster.

mm201 commented 9 months ago

This is a huugge PR with lots of changes. Did you use an automated tool to do this? I think it would be easier if you could provide instructions on how I can do this optimization rather than checking over each individual image.

SombrAbsol commented 9 months ago

Yup, I've used several Windows programs to do this. Recommended tools are, in order of effectiveness, ECT (Efficient Compression Tool), pingo, PNGOut and ZopfliPNG.

For this pull request, I've only used ECT and pingo, because in my experience with these tools, they are generally faster and more efficient than PNGOut and ZopfliPNG. What's more, the process quickly becomes lengthy once you have a lot of images and use all the tools one after the other, as is the case here.

To reproduce the result :

@echo on
for /R %%A in (*.png) do (
    ect -9 -strip "%%A"
    pingo -s4 -lossless -strip "%%A"
)

Once you've placed the folders containing the images to be compressed, run the .bat file. The parameters are such that the programs automatically search for the best possible compression and remove metadata from the files.

If you also want to use PNGOut and ZopfliPNG (which I haven't done here because it's extremely time-consuming):

To use ZopfliPNG, you'll also need to install Cygwin and run the package installer (https://www.cygwin.com/install.html) at least once. If you don't want to keep Cygwin in the future, go to C:\cygwin64\bin and copy the following files into the folder you're using:

Finally, save the following script in a .bat file:

@echo off
for /R %%A in (*.png) do (
    ect -9 -strip "%%A"
    pingo -s4 -lossless -strip "%%A"
    pngout "%%A"
    zopflipng -m -y "%%A" "%%A"
)

Once you've placed the folders containing the images to be compressed, run the .bat file.