Optimizing Images for web right the easy way

· 1 min read June 30, 2022


Large graphics slow down your web pages, resulting in a less-than-ideal user experience. Image optimization is the process of reducing the file size of photos using a plugin or script, which in turn reduces the page load time.

One of the easiest ways to optimize images without losing on quality is converting them to webp .

WebP is a recent image format that offers greater lossless and lossy compression for web-based image compression. Web developers can use WebP to create smaller, richer graphics that speed up the web.

When compared to PNGs, WebP lossless images are 26% less in size. Lossy WebP images are 25-34 percent smaller than comparable JPEG images with the same quality level.

Now we know why we want to convert images to webp , lets see how to do it .

Using Online Converters .

In the past i used to convert images to webp using online converters like : cloud convert . The problem with online converters is they are very slow and there are images size limits .

Using CLI WEBP Converter .

Well good for us there is a cli webp converter called cwebp ( by google ) . That can help us convert images to webp easily ..

If you are on debian you can easily install it like :

  sudo apt-get install webp 

Detailed installation guide can be found here.

Converting images with cwebp is pretty simple :

cwebp -q 80 image.png -o image.webp

arg -q is the quality of compression (0-100 , default is 75) . image.png is the input file and arg -o specifies the output file .

Detailed docs can be found here.

Resources :

Some Thing to say ?