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

how to avoid compress same png multi times #374

Open
ruidge opened this issue Mar 29, 2021 · 6 comments
Open

how to avoid compress same png multi times #374

ruidge opened this issue Mar 29, 2021 · 6 comments

Comments

@ruidge
Copy link

ruidge commented Mar 29, 2021

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

ruidge commented Mar 29, 2021

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

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

ruidge commented Mar 30, 2021

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

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

ruidge commented Mar 31, 2021

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

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

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

No branches or pull requests

2 participants