Skip to content

PNG: lossless compression#124

Open
SombrAbsol wants to merge 1 commit intomm201:masterfrom
SombrAbsol:master
Open

PNG: lossless compression#124
SombrAbsol wants to merge 1 commit intomm201:masterfrom
SombrAbsol:master

Conversation

@SombrAbsol
Copy link

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

@mm201
Copy link
Owner

mm201 commented Nov 12, 2023

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
Copy link
Author

SombrAbsol commented Nov 12, 2023

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:

  • cyggcc_s-seh-1.dll
  • cygstdc++-6.dll
  • cygwin1.dll

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants