Logo for the site

How to convert a .png file to a .webp using the commandline

This will give you the chance to convert a .png file to .webp when ever you want without using a 3rd party website.

  • #homebrew
  • #bash
  • #image convertion
  • #image optimisation

First of you will need to install webp thru you commandline using this command

brew install webp

After that you will need to `cd` into the directory that you image resides. And after that you will need to write this command.

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

`cwebp` stands for compression of the file.

`-q` is the flag for declaring the quality of the image were you will enter a number from 1 to 100. Google recommends that you atleast have a quality value of 80.

`example.webp` is were you state the image file you want to convert.

`-o` is used for declaring what the output should be of the `cwebp` command. So if you write `-o example.webp` you will get a image with the file name example.webp but if you want it to go elsewere in your filesystem just write the disired path.

Tweet this snippet

Edit on github

call-n

Passionate software engineer trying to learn as much about code and design

Links

All rights reserved © calo.dev 2022