Original intention
tinypng The web version is actually quite convenient. But he has a limit on the number of uploaded pictures. For example, only 20 pictures can be uploaded per day. If this number is exceeded, the error Too many files uploaded at once
will appear intermittently. That's why I decided to use Node to develop an npm package that bypasses the number limit.
Instructions
installation:
npm i tinypngpro -g
Usage
Then, enter the directory where you want to compress the picture on the command line and execute:
To shrink all PNG images within the current directory.
tinypngpro .
To shrink all PNG images within the current directory and subdirectoies, use the -r
flag
tinypngpro . -r
To shrink all PNG images within a specific directory (assets/img
in this example), you may run the following command.
tinypngpro assets/img
Description
-tinypng has a limit on the number of user uploads by default, using the X-Forwarded-For
header to bypass this limitation
-For simplicity, it is not possible to traverse folders recursively
-For simplification, configuration is not supported, only pictures in the current directory can be compressed, and an output directory will be created in the current directory, and the successfully compressed pictures will be placed in it