kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 486 forks source link

how to avoid compress same png multi times #374

Open ruidge opened 3 years ago

ruidge commented 3 years ago

I write a script to compress all png in the project. the command is ' pngquant --skip-if-larger --speed 1 --nofs --strip --force --output "xx.png" -- "xx.png" '. It works well in 1st time compress, but the script still compress some png in 2nd, 3rd time . I compare the result the 2nd or 3rd compress just reduce 0.0x kb or 0.x kb size. What can I do to avoid these compress.(avoid compress same png multi times ). custom command args or record png name myself or other graceful?

ruidge commented 3 years ago

I write a script to compress all png in the project. the command is ' pngquant --skip-if-larger --speed 1 --nofs --strip --force --output "xx.png" -- "xx.png" '. It works well in 1st time compress, but the script still compress some png in 2nd, 3rd time . I compare the result the 2nd or 3rd compress just reduce 0.0x kb or 0.x kb size. What can I do to avoid these compress.(avoid compress same png multi times ). custom command args or record png name myself or other graceful?

I use ImageMagick to see png's metadata and compare the compressed and origin meta, and list some diff: change Type (TrueColorAlpha -> PaletteAlpha); change Red ,Green, Blue's min ,add Histogram ; then I update the script, read the meta before compress , only compress when Type != PaletteAlpha, is this fine?

kornelski commented 3 years ago

You can skip PNG files that have type PaletteAlpha.

Or you don't have to do anything — if you don't use quality setting, then pngquant won't do anything to such files.

ruidge commented 3 years ago

You can skip PNG files that have type PaletteAlpha.

Or you don't have to do anything — if you don't use quality setting, then pngquant won't do anything to such files.

so what cause 0.0x kb or 0.x kb's reduce and what is --quality default value(s)?

kornelski commented 3 years ago

quality default is 0-100, which means it does as good as it can, accepts any result. for png8 it always achieves 100%.

small reduction can be due to lossless recompression.

ruidge commented 3 years ago

quality default is 0-100, which means it does as good as it can, accepts any result. for png8 it always achieves 100%.

small reduction can be due to lossless recompression.

If so, I may compress all png every time. by the way, how about pngquant compatibility on mobile devices, Android, iOS, web on chrome ?

kornelski commented 3 years ago

PNG written by pngquant are standard and work on all platforms.