Not only can JPG images be optimized, so can PNG files. There are several applications for this purpose, in this post we will focus on one in particular: OptiPNG.
OptiPNG is a small tool that allows us optimize PNG images -and convert others to this format- without losing absolutely anything of quality along the way. It is a tool that does not have a graphical interface, although its use through the console is really simple. The basic command to reduce the size of our PNG images is:
So simple. Still OptiPNG has a lot of configurable parameters that will help us customize the optimization process. For example, if we want keep the original file we will use the option
Suppose our image is located at the root of our home directory and we want to optimize it without losing the original file. For this purpose we will use the command:
optipng -k $HOME/imagen.png
Still OptiPNG chooses the best compression level, We can also set manually. To do this we use the option
, And can set values from 1 to 7, with 7 being the maximum level. Taking the above example, suppose we want to add a custom compression of 5 as well; then we run:
optipng -k -o5 $HOME/imagen.png
If we want to run the above command for all images in a directory, We use:
optipng -k -o5 $HOME/directorio-de-las-imágenes/*.png
To access the full list of OptiPNG options we just have to run
It should be noted that the compression performed by OptiPNG is a loss of quality so we certainly will not get results as drastic as those offered by some online services, such as TinyPNG, in which the images do lose some quality, something notable especially in those containing gradients.
OptiPNG is in the official repositories of Ubuntu, so to install the tool just run on our terminal:
sudo apt-get install optipng
Learn more – Adjust the screen brightness with Xbacklight, How to free up RAM in Ubuntu