In the last article, we told you how to compress images in JPEG format. Now we will tell you how to solve a similar problem, but already in relation to images with PNG format.
PNG is a very popular image extension. The format was developed as a replacement for GIF. The size of PNG images is often very different in terms of color depth, interlacing, and also due to a certain compression algorithm.
OptiPNG is a unique console program with which it is possible to compress PNG images. All major and minor tasks can be implemented using OptiPNG. This can be done just as quickly and without loss in quality as in the case of JPEG images.
Do you work in Ubuntu? You can install the program without any problems from the repository. You need to run the following command:
$ sudo apt install optipng
Compressing images using OptiPNG
The syntax of the utility is very simple. It can be executed in the same way as in the case of jpegoptim:
$ optipng options file_name.png
Consider the utility options:
Let's perform png optimization. Let's find out how much the file weighs:
$ df -h image.png
To compress the file, we use:
$ optipng image.png
We look at the size, we do not see any differences, the image is very small, but when the size increases, the difference will be visible:
PNG compression occurs without loss of quality, you will get the same image, but smaller. It is necessary to indicate the degree of optimization that affects the time losses associated with the implementation of the image optimization program. The degree is set from 0 to 7. The higher it is, the more time and resources the PC will need.
$ optipng -o 7 impge.png
Batch processing of images is performed similarly with jpeg:
$ cd images/
$ optipng *.png
That's all, again, nothing complicated.
Apply the discount by inserting the promo code in the special field at checkout: