Batch process .png to .webp

user2111006 picture user2111006 · Oct 25, 2014 · Viewed 14.8k times · Source

I have around 100 .png images, and all of them have to be converted to .webp (Google's image format). I am using Google's CLI tool. Any idea how to batch process them.

Answer

InfinitePrime picture InfinitePrime · Oct 25, 2014

You can do it with a help of a simple bash script.

Navigate to the directory where your images reside and execute this:

$ for file in *
> do
> cwebp -q 80 "$file" -o "$file.webp"
> done

You can change the output file name, as you want. But should end with a .webp extension.