Converting images to the WebP format is easy by using cwebp command line tool from Google.
This tool converts JPG, PNG, and TIFF images to WebP.
Setup Process: (Windows)
Step 1: Download cwebp tool from this page.
Step 2: Unzip the downloaded file then jump straight to C drive and create a new directory (ex: Dev Tools).
Copy this path.
Step 3: Search Environment variables.
Step 4: System properties window quickly pop up there navigate Advanced tab -> Environment variables…
Step 5: Under Environment variables, Path -> Edit -> New.
Step 6: Paste the address we had copied here.
Then click OK multiple times and close all open windows.
Step 7: Open your image directory and type cmd on the address bar and hit enter.
Step 8: Type cwebp command and hit enter.
If you see something similar screen then you have successfully set up cwebp tool in your computer.
Step 9: The tool takes a single image as input and the file name of the converted image as output, for example:
cwebp myimage.jpg -o myimage.webp
The default compression level is 75. If you want to manually control the compression level then use following command:
cwebp -q 80 myimage.jpg -o myimage.webp
On the above command, the quality compression factor is 80.
However, running the cwebp command one image at a time like this would take a long time to convert many images. If you need to do this, you can use a script instead.
`for file in images/*; do cwebp -q 75 "$file" -o "${file%.*}.webp"; done`
This script converts, at a quality of 75, all the files in the images/ directory, and saves them as a new file (same filename, but with a .webp file extension) in the same directory.
Quick Links
Legal Stuff