Converting Images to WebP From Terminal

Are you using a modern image format for your website image?

Shinichi Okada
mkdir Awesome

--

Image by Text To Photo Editor. Background photo by Héctor J. Rivas on Unsplash

While optimizing Flowbite-Svelte website, Ligthhouse suggested to use WebP files instead of PNG and JPG files. So I created a Bash Script called Consize (CONvert and reSIZE).

After optimizing the images and adding meta tags, I got almost perfect scores.

Chrome Lighthouse showing scores. Screenshot by the author.

After converting to WebP and resizing, an original image became very small in the size.

Image size comparisons. Image by the author.

Requirements

This script requires imagemagick and webp are installed on your system.

If you are a macOS user:

brew install imagemagick
brew install webp

Debian/Ubuntu user:

sudo apt install imagemagick
sudo apt install webp

Installation

Let’s install consize to your system. Select one of the following installation method.

--

--

Shinichi Okada
mkdir Awesome

A programmer and technology enthusiast with a passion for sharing my knowledge and experience. https://codewithshin.com