Search code examples
powershellimage-processingcmdimage-compressionwebp

How to convert my photos to webp format of Google in windows 8.1?


I want to convert my photos from jpg, gif, and png to WebP format.

When I'm trying to use CMD for using cwebp command, I got this error message :

'cwebp' is not recognized as an internal or external command, operable program or batch file.

What should do I do?

I've downloaded all the files needed such as libwebp-0.4.0-windows-x86.zip and WebpCodecSetup.exe.

Even I've installed Visual Studio to use its command prompt, but didn't work! Is there anyone who can help me?

One more question:

Is anyone know any tool to reduce image size without losing its quality?


Solution

  • Download cwebp binaries (.exe) and run it with PowerShell:

    # tip: on windows explorer shift + right-click a directory and copy its path
    $dir = "path/to/photos/directory"
    
    # get all files in the directory
    $images = Get-ChildItem $dir
    
    foreach ($img in $images) {
      # output file will be written in the same directory 
      # but with .webp extension instead of old extension
      $outputName = $img.DirectoryName + "\" + $img.BaseName + ".webp"
    
      C:\webp-converter\libwebp-0.6.1-windows-x64\bin\cwebp.exe $img.FullName -o $outputName
    }
    

    See also cwebp options.