Modern web is more about compression and one of it are images. There are many things which can be minified and compressed like CSS, JS, server side compression and even HTML of the page. Here I am going to show you how to convert PNG images to WebP format with Imagemagick while maintaining the same quality but reduced size.
Imagemagick is a library which can help us convert, edit raster and vector images. We will use the shorthand tool provided by Imagemagick called
Open terminal in your favorite Linux distribution and install Imagemagick if not installed.
sudo pacman -S imagemagick
For Ubuntu and similar it would be:
sudo apt install imagemagick
The simplest form of usage is to use minimal options and get the job done.
magick src.png -quality 50 -define webp:lossless=true out.webp
magick = shorthand command to execute
src.png = the image which we want to convert
-quality = here we enter the quality of the output image, I like to keep it at 50
-define = this is for defining a few extra options, e.g lossless
out.webp = the final output webp file
Remember there are other combination of flags and options. It falls under the requirement and what one need from the final output.