This can be done by downloading the official cwebp command line encoder from Google, and then adding its bin folder to your PATH (environment variable). Then, create a batch file that takes a file and runs it through cwebp with your preferred settings. Finally, use a .reg file or a downloaded utility, such as Easy Context Menu, to add your batch file to the right-click context menu for files.
Step 1: Download and extract libwebp from Google
(64-bit) Offical Download for libwebp Version 1.1.0
(32-bit) Offical Download for libwebp Version 1.0.3
Extract the folder to your preferred location and take note of the folder path so that we can use it in Step 2.
Step 2: Add libwebp's bin folder to your PATH
Open the Run Dialog box by pressing WinKey+R. Alternatively, right-click on the Start button and left-click on Run. Type the following:
SystemPropertiesAdvanced
Press Enter.
The "System Properties" Dialog opens with the "Advanced" tab selected.
Press the "Environment Variables..." Button located after the Startup and Recovery section at the bottom right. The "Environment Variables" dialog opens.
In the "User Variables for " section at the top, left-click the list item that has "Path" listed in the Variable column. Click the Edit button underneath the "User Variables for " list box. The Edit Environment Variable dialog opens.
Click New on the top right to add an entry. Type or paste in the location of libwebp's bin folder that we extracted in Step 1.
If the folder was extracted inside a user's download folder, and that user was named "Administrator", then the folder location string would look like the following:
C:\Users\Administrator\Downloads\libwebp-1.1.0-windows-x64\bin
After ensuring the path is correct, press enter.
Click OK on the "Edit Environment Variable" Dialog.
Click OK on the "Environment Variables" Dialog.
Click OK on the "System Properties" Dialog.
The location of libwebp's bin folder has now been added to your PATH (environment variable.)
Step 3: Create a batch file that converts a file to .webp using cwebp
In this step we will be creating a batch file that looks something like this:
cwebp -q 50 -m 6 -af -f 50 -sharpness 0 -mt -v -progress %1 -o %~n1.webp
Explanation
cwebp This references a specific executable file located in our libwebp's bin folder that can convert images to webp.
-q 50 The "compression factor for RGB channels between 0 and 100"
Here we use 50 for moderate compression.
-m 6 The compression method with values ranging from 0 to 6. 6 is the maximum so we get the smallest file size.
-af Turns auto-filter on. Gives us optimized quality.
-f 50 Deblocking filter (Smoothness) (0-100)
-sharpness 0 Sharpness range with 0 being the most sharp and 7 being the least sharp
-mt Use multi-threading for encoding, if possible.
-v Print extra information (encoding time in particular).
For more information on command line switches that you can use with cwebp, see Google's WebP Guide on cwebp
%1 is the first argument supplied to the batch file, in this case, it will be the file we selected and right-clicked in Windows Explorer.
We include the final switch:
-o %~n1.webp
where -o tells cwebp to write out to a file, %~n1 prints the name of the original file without the file extension, to which we add our new extension .webp
Important: Save this file with a .bat file extension in a location where the current user has permissions to access and execute it. In our example, the current user's downloads folder will be used and the file is named webp.bat. This is the example path to our batch file:
C:\Users\Administrator\Downloads\webp.bat
Step 4: Modify the System's Right Click context menu for files
If you are comfortable editing your systems registry, and you know how to create a backup of it, you may find option 1 suitable. If not, option 2 provides a safer way to modify your system.
Option 1: Modify the registry
In this step we create and run a .reg file that looks like this:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Run script]
@="Run &script"
[HKEY_CLASSES_ROOT\*\shell\Run script\command]
@="\"C:\\Users\\Administrator\\Downloads\\webp.bat\" \"%1\""
Explanation
HKEY_CLASSES_ROOT\*\shell\Run script
Adds an entry into the context-menu for all files on the system named Run script
@="Run &script"
Here we have the name that shows in the context menu. The & symbol denotes which key on the keyboard the user can press to access this context-menu entry
HKEY_CLASSES_ROOT*\shell\Run script\command
Here is the command for our previous entry under the name Run script
@="\"C:\Users\Administrator\Downloads\webp.bat\" \"%1\""
This is the path to our saved batch file from step 3.
Option 2: Use Easy Context Menu v1.6
You can download Easy Context Menu v1.6 here.
Once you have downloaded, extracted, and opened EcMenu.exe or EcMenu_x64.exe, depending on your system (32-bit or 64-bit), press Ctrl+E to open the "List Editor" dialog. Alternatively, you can click on the File menu and click on the third option which is "List Editor"
The "List Editor" dialog appears, scroll down to File Context Menu and left-click on it. Then press the "Add New" button at the bottom of the window. The File selection dialog appears.
Navigate to the folder where you saved the batch file in Step 3. For our example we navigate to our Downloads folder. Change the type of files shown in the dialogs file list from "Application Files (*.exe)" to "Application Files (*.*)" by left clicking on the dropdown box at the bottom right above the open button. Double left-click on the batch file. In our example, this file is named webp.bat.
You can change some of the settings like where it will be displayed in the context menu.
Once you are done, press the "Save Changes" button at the bottom left and close the "List Editor" dialog.
I have tested this solution myself, on my Windows 10 Pro 1903 using Option 2 in Step 4, using the Easy Context Menu utility. I can right-click on files and use the context menu to convert them to webp. The command window pops open with the progress and it closes when it is done, and I have a new file that is the same image, but in webp format.