Use pngquant to compress png images,
When it comes to png Image Compression, many people may know the website TinyPNG. However, if the PS plug-in requires money (although cracked), the Developer API will be connected to his server. without mentioning the network transmission speed, the Key is also subject to monthly restrictions.
But it seems that tinyPNG uses the technology from pngquant, at least in the http://pngquant.org/, so it claims: TinyPNG and Kraken. io-on-line interfaces for pngquant. If this is the case, I would like to talk to TinyPNG. The latter is open-source, and even the GUI tools provided on the home page are open-source. In addition, the principles of TinyPNG on the home page do not mention pngquant at once.
I used the pngquant command line to run the example graph on the tinyPNG homepage. The compression ratio and display effect are similar.
Pngquant tools on the home page, Pngyu (http://nukesaq88.github.io/Pngyu/) is cross-platform and open source, I think it is quite easy to use, directly put the folder inside the drag can recursive processing, supports various forms of generation (renaming, overwriting, storage to other directories, etc.), compression ratio after compression, and preview.
However, I still want to be able to process it through scripts. On the one hand, it is more customizable, and on the other hand it is more convenient to integrate it into the entire automated process chain. So I tried to write something in python again. Who knows ......
Pngquant's command line method is a bit pitfall ...... The parameter descriptions in help are inconsistent with the actual results.
1. The -- force parameter is invalid. If the output file exists, an error is returned. Ignore this parameter and specify the overwriting parameter.
2. The -- skip-if-larger parameter is abnormal. Sometimes the generated file is small and will be dropped by the skip ......
But fortunately, the python method is good. Although the command line itself cannot handle these problems, python can be processed at the upper layer. below is the actual recursive processing of png scripts in a folder: