HomeOur Team

How to convert multiple images to WebP

By Vitus White
Published in How To
April 15, 2022
1 min read

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.

batch-process-multiple-images-WebP-cwebp-img-2

Step 2: Unzip the downloaded file then jump straight to C drive and create a new directory (ex: Dev Tools).

batch-process-multiple-images-WebP-cwebp-img-3

Copy this path.

Step 3: Search Environment variables.

batch-process-multiple-images-WebP-cwebp-img-4

Step 4: System properties window quickly pop up there navigate Advanced tab -> Environment variables…

batch-process-multiple-images-WebP-cwebp-img-5

Step 5: Under Environment variables, Path -> Edit -> New.

batch-process-multiple-images-WebP-cwebp-img-6

Step 6: Paste the address we had copied here.

batch-process-multiple-images-WebP-cwebp-img-8

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.

batch-process-multiple-images-WebP-cwebp-img-9

Step 8: Type cwebp command and hit enter.

batch-process-multiple-images-WebP-cwebp-img-10

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

batch-process-multiple-images-WebP-cwebp-img-11

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.


Tags

webp
Previous Article
How to Make Facebook Posts automate from you're blog
Vitus White

Vitus White

Web Developer

Related Posts

How to block a game or program from accessing the Internet on Windows?
May 18, 2022
1 min
© 2022, All Rights Reserved.

Quick Links

Our TeamContact Us

Legal Stuff

Social Media